XIInfo Pract H Y 416
XIInfo Pract H Y 416
XIInfo Pract H Y 416
--1--
11. Which of the following memory types cannot store the data or information 1
permanently? a) Flash memory b) RAM c) DVD d) Hard disk
12. Which of the following are valid identifier(s)? 1
a. roll no b. _rollno c. roll_no d. roll-no e. rollno f. num01
13. Which of the following is an escape sequence for a newline character? 1
a. \a b. \t c. \b d. \n
14. What values are generated when the function list(range(8,0,-2)) is executed? 1
a. [8,4] b. [8,4,2,0] c. [8,6,4,2,0] d. [8,6,4,2]
15. What is the output produced when this code executes? 1
k=0
for i in range(4,8):
if i%2 ==0:
k=k+i
print(k)
a. 4 b. 8 c. 10 d. 18
16. If L=[1,2] then L*2 will yield: 1
a. [1,2]*2 b. [1,2,2] c. [1,1,2,2] d. [1,2,1,2]
17. Given a list L = [10,20,30,40,50,60,70,80], what would L[-3:99] return? 1
a. [20,30,40] b. [30,40,50] c. [40,50,60] d.[60,70,80]
--2--
Section C
26. What will be the output of following code- 3
1. >>>a={i: 'Hi!' + str(i) for i in range(5)}
>>>a
2. >>> a={i: i*i for i in range(6)}
>>>a
3. >>>dict1 = {"key1":1, "key2":2}
>>>dict2 = {"key2":2, "key1":1}
print(dict1 == dict2)
27. Rewrite following code after removing errors (if any): 3
N=100
A= “Number” +5
B= 2N +20
Print(B)
28. Write a program to print following series – 3
2,4,8,16, …………….
Expected Output:
Enter the terms=5
2,4,8,16,32,
29. What is difference between break and continue statement in Python explain 3
with an example.
30. Find the output of the following code: 3
>>> L=["These", "are", "a", ["few", "words"], "that", "we", "will", "use"]
>>> print (L[3:4])
>>> print (L[1:4:-1])
>>> print ("few" in L)
>>> print (L[0::2])
>>> print (L[4:])
>>> print (L)
Section D
31. What will be the output of the following code? 4
i. type(34)
ii. a, b=10,20
a, b= b, a+b
print(a, b)
iii. a=20 + 4j
print(a.real + a.imag)
iv. print(10,20,30, sep=’*’,end=’@’)
32. 1. Write a python program to print a sum of series up to 10 integers using for 4
loop.
2. Write a program to input a list of numbers and find the smallest and largest
number from the list.
Expected Output:
how many elements to be entered: 4
enter elements : 1
enter elements : 2
enter elements : 5
enter elements : 4
Largest element in the list is 5
Smallest element in the list is 1
--3--
Section E
33. What will be the output of the following python code? 5
(a) [11, 14, 18, 10, 15]
(b)['P', 'Y', 'T', 'H', 'O', 'N']
(c) L1.insert(0,12)
(d) L1.sort()
(e) L1.remove(14)
(f) L1.append(5)
(g) L2.pop()
(h) L1+L2
(i) L1.extend([12,16,18])
(j) L1*2
34. Explain the following : 5
1. What is syntax error? Give one example.
2. What is the difference between ‘=’ and ‘==’? Explain with the help of an
example.
3. What do you understand by precedence of operators? What is the
precedence of arithmetic operators?
35. a. Write a Python program to create a dictionary to store names of states 5
and their capitals.
b. Write a Python program to create a third dictionary from two
dictionaries in the way so that the values are shown in third dictionary.
--4--