XIInfo Pract pt2316
XIInfo Pract pt2316
INSTRUCTIONS:
a) F1 b) F5
c) F3 d) F7
Q4. Which of the following are valid Identifiers? 1
a) my name b) _myname
c) myname d) my-name
Q5. Operating System is an example of 1
a) Identifiers b) Functions
c) Keywords d) Literals
Q7. To print the value of a variable, Python uses 1
a) integer b) string
c) floating point d) none of these
Q9. In Python , a variable may be assigned a value of one type, and then 1
later assigned a value of a different type. This concept is known as
…………….
pg. 1
XIC/IP/PERIODIC II
a) Mutability b) Static typing
c) Dynamic Typing d) Immutability
Q10. Which of the following is not an immutable type in Python. 1
a) String b) Tuples
c) Set d) Dictionary
Q11. In the following expression x=a+5-b, a and b are …………………. 1
a) Operator b) Operands
c) Expression d) Equation
Q12. What values are generated when the functions range(6,0,-2) is 1
executed
a) [4,2] b) [6,4,2,0]
c) [4,2,0] d) [6,4,2]
Q13. Consider the following loop given below: 1
for i in range(10,5,-3):
print(i)
How many times this loop run
a) 3 b) 2
c) 1 d) Infinite
Q14. An empty / null statement in Python is …………….. 1
a) go b) pass
c) over d) ;
Q15. What will be the output of the following Python code? 1
d1={‘a’:10,’b’:2,’c’:3}
str1=’ ’
for i in d1:
str1=str1+str(d1[i])+” “
str2=str1[:-1]
print(str2[::-1])
a) 3,2 b) 3,2,10
c) 3,2,01 d) Error
Q16. Which of the following will always return a list? 1
a) max() b) min()
c) sort() d) sorted()
Q17. Which of the following can delete an element from a list if a index of the 1
element is given?
a) pop() b) remove()
c) del d) all of the above
Q18. What would the following code print? 1
pg. 2
XIC/IP/PERIODIC II
d={‘Spring’:’autumn’,’autumn’:’fall’,’fall’:’spring’}
print(d[‘autumn’]
a) autumn b) fall
c) spring d) Error
Q19. Given a list L=[10,20,30,40,50,60,70], what would L[2:-2] return 1
a) [10,20,30,40] b) [20,30,40,50]
c) [20,30,40] d) [30,40,50]
Q20. Dictionaries are also called…………………. 1
a) Mapping b) Hashes
c) associative arrays d) all of these
pg. 3
XIC/IP/PERIODIC II
Q33. Predict an output of the following: 2
my_list=[‘c’,’l’,’a’,’s’,’s’,’i’,’c’]
my_list[2:3]=[]
print(my_list)
my_list[2:5]=[]
print(my_list)
Q34. Find the error: Rewrite the code in correct form. 2
list1=[4,9,7]
list2=list1*[3,5]
print(list1*3.0)
print(list2)
Q35. Create a dictionary ODD of odd numbers between 1 and 10, where the 2
key is the decimal number and the value is the corresponding in words.
Write the answer and perform the following operations on this dictionary:
a) Check if 7 is present or not
b) Retrieve the value corresponding to the key 9
Q36. Predict an output of the following code: 2
myDict={‘a’:27,’b’:43,’c’:25,’d’:30}
valA=’’
for i in myDict:
if i>valA:
valA=i
valB=myDict[i]
print(valA)
print(valB)
Q37. Ask the user to enter a list containing numbers between 1 and 12 Then 3
replace all the entries in the list that are greater than 10 with 10.
Q38. Write a program to create a dynamic dictionary to store names of states 3
and their capitals.
Q39. Write a program in Python which inputs a list of numbers and find out 3
the maximum and minimum element of it. For an example, if a list is
[82,23,34,45] then output will be maximum=82 and minimum=23
Q40. Write a program to calculate the sum of odd numbers divisible by 5 from 3
the range(1….100)
Q41. Write a program to find the area of circle. 3
Q42. Write a program to find the simple interest based principal amount, rate 3
and time (Hints: Simple Interest= (principal amount*rate*time)/100
pg. 4
XIC/IP/PERIODIC II