Page 74 - PYTHON-11
P. 74
25. What will be the output of the following code? (2)
import random
print(random.randint(5, 10) - random.randint(1, 3))
26. Write any two ways to import a Python module using example. (2)
27. (a) What are the differences between dictionary and list? (2)
OR
What are the differences between dictionary and tuple?
(b) Write a Python statement to generate a random number between 0 and 20.
OR
Write a Python conditional statement to check whether the entered number is a multiple of 7 or not.
28. (a) Explain is and is not operators with the help of examples (2)
OR
(b) Explain input() and eval() functions with the help of example.
Section-C (3 × 3 = 9 Marks)
29. (a) Write a Python program to sort the elements of a list in descending order. (3)
OR
(b) Write a Python program to input n numbers from the user, store these numbers in a tuple and then
print the maximum and minimum number along with the sum and the mean of all the elements
from this tuple.
30. (a) Explain any 3 built-in methods of string along with syntax and examples. (3)
OR
(b) Explain any 3 built-in methods of tuple along with syntax and examples.
31. Predict the output of the following code. (3)
val = {}
val[2] = 10
val['2'] = 2
val[2]= val[2]+5
count = 0
for i in val:
count += val[i]
print(count)
OR
lst = [50, 37, 65, 'Rakesh', 90, 35]
lst.append('Simran')
print("The List is:", lst)
for j in range(2, 6):
lst.insert(j, j * 3)
print("Final List is:", lst)
Section-D (4 × 4 = 16 Marks)
29. (a) Consider the following code. (4)
import random
str="ITTECHNOLOGIES"
num=random.randint(0,3)
n=10
while str[n]!="O":
print(str[n] + str[num] + "#", end = " ")
num= num+1
n=n-1
What possible output(s) will be displayed on the screen at the time of execution of the program from
the given code? Specify the minimum and maximum values that can be assigned to variable ‘num’.
OR
P.7