python class_12_1 (1)
python class_12_1 (1)
3) Write a statement in python to declare a dictionary whose keys are ‘Harddisk’,’Pendrive’,’Mouse’ and
values are 5000, 650 and 875 respectively
6) If the following code is executed, what will be output of the following code ?
Name =”Python-string_slicing”
print(name[-10 : 15])
10) List1=[15,25,35,40]
a) Display maximum value from the given list
b) To remove the 2nd and 3 rd element from the given list
11) Write the output of the following code. How many times will the following loop iterate ?
for j in “absolute”:
if i>=’t’ :
break
print(j, end= ‘ ‘)
d1=dict[ ]
i=1
n = input(“Enter number of records :”)
while i <=n :
a= input(“Enter name of the student:”)
b= input(“Enter phone number of the Employee :”)
d1(a)=b
i = i +1
l =d1.key[ ]
for i in l :
print(i, ‘\t’,’dl[i]’)
s="welcome2cs"
n = len(s)
m=""
for i in range(0, n):
if (s[i] >= 'a' and s[i] <= 'm'):
m = m +s[i].upper()
elif (s[i] >= 'n' and s[i] <= 'z'):
m = m +s[i-1]
elif (s[i].isupper()):
m = m + s[i].lower()
else:
m = m +'&'
print(m)
16) Write the program in Python to shift the negative numbers to left and the positive numbers to right so that
the resultant list will be as follows :
Original list [-2,1,-3,-15,16,-17,5,-3,-6]
Output should be [1,16,5,-6,-3,-17,-15,-3,-2]
17) Write a python program to input names of ‘n’ employees and their basic . Calculate house rent (30% of
basic salary ) , conveyance allowance(1% of basic salary), PF(9% of basic salary) and (gross salary = basic
salary + house rent + conveyance allowance - PF). Also display all the details.