Page 70 - PYTHON-11
P. 70
23. Differentiate between for and while loop. [2]
24. ‘Python is a dynamically typed and case-sensitive programming language’. Justify the statement. [2]
25. What will be the output of the following code? [2]
import random
print(random.randrange(2, 12, 2))
26. What is the difference between import module and from module import function? [2]
27. (a) What is the purpose of the pass statement in Python? [2]
Or
(b) What is the use of is operator in Python?
28. (a) Write a program to check whether a number is positive, negative or zero. [2]
Or
(b) Write a program to check whether a number is divisible by both 3 and 5.
Section C (3 × 3 = 9 Marks)
29. (a) Write a Python program to find the sum of all even numbers in a list. [3]
Or
(b) Write a Python program to store names of 5 students and their marks in a dictionary and display them.
30. (a) Differentiate between indexing and traversing of string. [3]
Or
(b) List the differences between a dictionary and a list.
31. Predict the output of the following code. [3]
items = {"pencils": 40, "notebooks": 25, "colors": 15}
items["notebooks"] += 30
items["markers"] = items.get("markers", 0) + 35
del items["pencils"]
for i in sorted(items):
print(i, ":", items[i])
Or
num = [15, 22, 39, 41, 15, 65]
num.remove(15)
num.append(93)
num.sort()
print(num)
Section D (4 × 4 = 16 Marks)
32. (a) Consider the following code. [4]
import random
data = []
lst = [103, 290, 430, 640]
for i in range(3):
index = random.randint(0, len(lst) - 1)
data.append(lst[index])
print(data)
P.3