Cs PPT 33
Cs PPT 33
[1]
5 What will be the output of the following code? 1
myList=[1,2,3,4,5,6]
for i in range(1,6):
myList[i-1]=myList[i]
for i in range(0,6):
print(myList[i],end=' ')
a. 2 3 4 5 6 1 b. 6 1 2 3 4 5
c. 2 3 4 5 6 6 d. 1 1 2 3 4 5
6 1
Consider the string str=”Green Revolution” choose the correct statements in
the python to display last four characters
(a) str[-4:] (b) str[:-4:] (c) str[::] (d) str[::-4]
9 How many times is the word “HELLO” printed in the following statement? 1
s='python rocks'
for ch in s[3:8]:
print('Hello' )
(a) 6
(b) 5
(c) infinite
(d) 8
10 1
What type of error is returned by the following code :
a={'a' : "Apple", 'b' : "Banana" , 'c' : "Cat"}
print(a[1])
[2]
11 Write the statement to add 50 in a tuple 1
>>>T=(10,20,30,40)
[3]
18 Assertion :Lists are similar to strings in a number of ways like indexing , 1
slicing and accessing individual elements.
Reason : Lists, unlike strings , are mutable.
SECTION B
19 2
What is the difference between extend( ) and append( ) functions?
22 2
Write the output of following Python code:
fruit_list1=['Apple','Berry','Cherry','Papaya']
fruit_list2=fruit_list1
fruit_list3=fruit_list1[:]
fruit_list2[0]='Guava'
fruit_list3[1]='Kiwi'
sum=0
for ls in(fruit_list1,fruit_list2,fruit_list3):
if ls[0]=='Guava':
sum+=1
if ls[1]=='Kiwi':
sum+=20
print(sum)
[4]
23 2
Write a program to remove vowels from a string
L=[2,3,4,6,9,3,8,9)
print (L.index(4))
print (L.count(3))
L.append (L.count(9))
print (L)
25 2
Consider the following dictionary capitals
capitals ={ "Maharashtra": "mumbai", "Delhi" : "New Delhi", "Uttar
pradesh":"Lucknow"}
Find the output of the following statements:-
(i) print(capitals.get("Lucknow"))
(ii) print(capitals.keys())
SECTION C
26 3
Start with the list[8,9,10].Do the following using list functions:
(a) Set the second entry(index1)to17
(b) Add 4,5 and 6 to the end of the list.
(c) Remove the first entry from the list.
(d) Sort the list
(e) Double the list.
(f) Insert 25 at index 3
27 3
Predict the Output:
Msg="CompuTer"
Msg1=''
for i in range(0, len(Msg)):
if Msg[i].isupper():
Msg1=Msg1+Msg[i].lower()
elif i%2==0:
[5]
Msg1=Msg1+'*'
else:
Msg1=Msg1+Msg[i].upper()
print(Msg1)
28 3
Write a program using dictionary to input total number of sections and
streams name of a class 11 and display all information on the output screen.
SECTION D
Find the answer for the following: 5
31
Results is a dictionary containing Name and Score of students in key: value
pair.
Results= {“A”:240,”B”:340,”C”:350,”D”:280,”E”:370}
a) Print name of all the students having score >250
b) Change marks of student “C” to 450.
c) Calculate average score in this class.
d) Add one more student with name “G” with score 290.
e) Delete entry of student “C” from it.
[6]
32 What does each of the following expressions evaluate to? 5
33 3+2=5
i). Write a program that takes a list ‘L’ as an argument, add 5 in all the odd
values and 10 in all the even values of the list L. Also display the list
ii) Input a string having some digits. Write a program to calculate the sum
of digits present in this string.
SECTION E
34. 4
Write a program to input line of text from the user until enter is pressed.
Count the total number of uppercase ,lowercase letters and count the total
number of alphabets, digits, symbols in the given text .
35. Write a program to create a dictionary with the roll number, name and 4
marks of n students in a class and display the names of students who have
marks above 75.
[7]
[8]