Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
x="malayalam"
y= list(range(1,10,-1))
print(x)
print(x.upper())
print(len(x))
rev=""
for l in range(1,len(x)+1,1):
print(x[-l])
rev=rev+str(x[-l])
print(rev)
if x==rev:
print(x + " is a Palindrom")
else:
print(x + " is not a Palindrom")
# write a program that returns a list that contains only the elements that are common between the lists (without duplicates). Make sure your program works on two lists of different sizes.
a = [1, 2, 1, 3, 5, 8, 13, 21, 34, 55, 89, 13, 21, 34, 55, 89]
b = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,13,13,2,2,7]
#first removing dups from each list
a.sort()
b.sort()
c=[]
d=[]
print(len(a))
print(len(b))
#for element in a:
#for countr in range(len(c)):
print(c)
for countr in range(len(a)):
if countr+1 == len(a):
break
else:
if str(a[countr])!=str(a[countr+1]):
c.append(a[countr])
for countr1 in range(len(b)):
if countr1+1 == len(b):
break
else:
if str(b[countr1])!=str(b[countr1+1]):
d.append(b[countr1])
print(c)
print(d)
if len(c)>len(d):
big=c
small=d
else:
big=d
small=c
common=[]
for big_element in big:
for small_element in small:
if big_element==small_element:
common.append(big_element)
print(common)
# 260
import numpy as np
import random
list9 = [[np.random.randint(0, 1000) for x in range(28)] for y in range(12)]
print list9
list10 = [[np.random.randint(0, 1000) for x in range(28)] for y in range(12)]
print list10
delta_list = [[0 for x in range(28)] for y in range(12)]
for i in range(12):
for j in range(28):
delta_list[i][j] = list9[i][j] - list10[i][j]
print(delta_list)
# Exam results program in Python
# marks={'English':67,'Maths':94,'Hindi':81,'Telugu':81,'Science':88,'Social':88}
marks={'English':6,'Maths':9,'Hindi':1,'Telugu':81,'Science':88,'Social':88}
total=0
for sub, score in marks.items():
print("In " + sub + ", You got " + str(score) + " Marks")
total=total + score
print("====================================================")
print("Scored a total marks of " + str(total) + "/600 Marks")
print("====================================================")
if total/600 < .60:
result="Passed in Second Class"
else:
result="Passed in First Class! Congratulations"
print(result)
import re
out = '7200-17# show ip interface brief | sec GigabitEthernet0\n\
Interface IP-Address OK? Method Status Protocol \n\
GigabitEthernet0/1 unassigned YES unset up up \n\
GigabitEthernet0/2 192.168.190.235 YES unset up up \n\
GigabitEthernet0/3 unassigned YES unset up up \n\
GigabitEthernet0/4 192.168.191.2 YES unset up up \n\
TenGigabitEthernet2/1 unassigned YES unset up up \n\
TenGigabitEthernet2/2 unassigned YES unset up up \n\
TenGigabitEthernet2/3 unassigned YES unset up up \n\
TenGigabitEthernet2/4 unassigned YES unset down down \n\
GigabitEthernet36/1 unassigned YES unset down down \n\
GigabitEthernet36/2 unassigned YES unset down down \n\
GigabitEthernet36/11 unassigned YES unset down down \n\
GigabitEthernet36/25 unassigned YES unset down down \n\
Te36/45 unassigned YES unset down down \n\
Te36/46 unassigned YES unset down down \n\
Te36/47 unassigned YES unset down down \n\
Te36/48 unassigned YES unset down down \n\
Virtual36 unassigned YES unset up up \n\
7200-17#\n\
7200-17# show interface atm0 | i BW\n\
MTU 4470 bytes, sub MTU 4470, BW 516 Kbit, DLY 80 usec,\n\
7200-17#'
print ('-------\n'+out+'\n--------\n\n')
if ('BW' in out) and ('Kbit,' in out):
bw = re.search('BW (\d+?) Kbit', out)
ge0 = re.search('(Gi.+0).+(down|up).+\n', out)
#if (int(bw.group(1)) >= 512):
# print ('ok to procced')
#else:
# print ('not good')
print ('---', bw.group(1),' int ', ge0.group(2),'--- di : ', d)
if ('Te36/45' in out):
print ("Its Ten 36")
if ('TenGigabitEthernet2/4' in out ):
print ('its Ten Gig Interface')
try:
d = re.search('Di', out)
print ('found Di : ' + d.group(1))
except AttributeError:
print ("\n\n error: AttributeError : can't find Di")
try:
a = (re.search('^(.+)#',out))
if ( a !=None):
print ('\n\nfound a :',a.group(1))
else:
print ('\n\n no Host Found')
except AttributeError:
print ("\n\n error: AttributeError")