πŸ“Š Python
Q. What will be the output of the following code snippet?
Code:
word = "Python Programming"
n = len(word)
word1 = word.upper()
word2 = word.lower()
converted_word = ""
for i in range(n):
 if i % 2 == 0:
   converted_word += word2[i]
 else:
   converted_word += word1[i]
print(converted_word)
  • (A) pYtHoN PrOgRaMmInG
  • (B) Python Programming
  • (C) python programming
  • (D) PYTHON PROGRAMMING
πŸ’¬ Discuss
βœ… Correct Answer: (A) pYtHoN PrOgRaMmInG
πŸ“Š Python
Q. What will be the output of the following code snippet?
Code:
a = "4, 5"
nums = a.split(',')
x, y = nums
int_prod = int(x) * int(y)
print(int_prod)
  • (A) 20
  • (B) 45
  • (C) 54
  • (D) 4,5
πŸ’¬ Discuss
βœ… Correct Answer: (A) 20
πŸ“Š Python
Q. What will be the output of the following code snippet?
Code:
square = lambda x: x ** 2
a = []
for i in range(5):
   a.append(square(i))
   
print(a)
  • (A) [0, 1, 4, 9, 16]
  • (B) [1, 4, 9, 16, 25]
  • (C) [0, 1, 2, 3, 4]
  • (D) [1, 2, 3, 4, 5]
πŸ’¬ Discuss
βœ… Correct Answer: (A) [0, 1, 4, 9, 16]
πŸ“Š Python
Q. What will be the output of the following code snippet?
Code:
def tester(*argv):
   for arg in argv:
       print(arg, end = ' ')
tester('Sunday', 'Monday', 'Tuesday', 'Wednesday')
  • (A) Sunday
  • (B) Wednesday
  • (C) Sunday Monday Tuesday Wednesday
  • (D) None of the above.
πŸ’¬ Discuss
βœ… Correct Answer: (C) Sunday Monday Tuesday Wednesday
πŸ“Š Python
Q. As what datatype are the *args stored, when passed into a function?
  • (A) List.
  • (B) Tuple.
  • (C) Dictionary.
  • (D) None of the above.
πŸ’¬ Discuss
βœ… Correct Answer: (B) Tuple.
πŸ“Š Python
Q. What will be the output of the following code snippet?
Code:
def tester(**kwargs):
   for key, value in kwargs.items():
       print(key, value, end = " ")
tester(Sunday = 1, Monday = 2, Tuesday = 3, Wednesday = 4)
  • (A) Sunday 1 Monday 2 Tuesday 3 Wednesday 4
  • (B) Sunday 1
  • (C) Wednesday 4
  • (D) None of the above
πŸ’¬ Discuss
βœ… Correct Answer: (A) Sunday 1 Monday 2 Tuesday 3 Wednesday 4
πŸ“Š Python
Q. As what datatype are the *kwargs stored, when passed into a function?
  • (A) Lists.
  • (B) Tuples.
  • (C) Dictionary.
  • (D) None of the above.
πŸ’¬ Discuss
βœ… Correct Answer: (C) Dictionary.
πŸ“Š Python
Q. Which of the following blocks will always be executed whether an exception is encountered or not in a program?
  • (A) try
  • (B) except
  • (C) finally
  • (D) None of These
πŸ’¬ Discuss
βœ… Correct Answer: (C) finally
πŸ“Š Python
Q. What will be the output of the following code snippet?
Code:
from math import *
a = 2.19
b = 3.999999
c = -3.30
print(int(a), floor(b), ceil(c), fabs(c))
  • (A) 2 3 -3 3.3
  • (B) 3 4 -3 3
  • (C) 2 3 -3 3
  • (D) 2 3 -3 -3.3
πŸ’¬ Discuss
βœ… Correct Answer: (A) 2 3 -3 3.3
πŸ“Š Python
Q. What will be the output of the following code snippet?
Code:
set1 = {1, 3, 5}
set2 = {2, 4, 6}
print(len(set1 + set2))
  • (A) 3
  • (B) 6
  • (C) 0
  • (D) Error
πŸ’¬ Discuss
βœ… Correct Answer: (D) Error