Hey Everyone,
We have prepared a quiz for you all. I hope you find it interesting and refreshes your memory a lil bit. Leave your answers down below and I’ll be sharing the answers with explanation later. Enjoy…!!
- What will be the datatype of the var in the below code snippet?
var = 10
print(type(var))
var = “Hello”
print(type(var))
a. str and int
b. int and int
c. str and str
d. int and str
- What will be the output of the following code snippet?
a = [1, 2, 3]
a = tuple(a)
a[0] = 2
print(a)
a. [2, 2, 3]
b. (2, 2, 3)
c. (1, 2, 3)
d. Error.
- What will be the output of the following code snippet?
a = [1, 2, 3, 4, 5]
sum = 0
for ele in a:
sum += ele
print(sum)
a. 15
b. 0
c. 20
d. None of these
- What will be the output of the following code snippet?
count = 0
while(True):
if count % 3 == 0:
print(count, end = " ")
if(count > 15):
break;
count += 1
a. 0 1 2 …… 15
b. Infinite Loop
c. 0 3 6 9 12 15
d. 0 3 6 9 12
- What will be the output of the following code snippet?
def func():
global value
value = “Local”
value = “Global”
func()
print(value)
a.Local
b. Global
c. None
d. Cannot be predicted