πŸ“Š Python
Q. What will be the output of the following code snippet?
Code:
a = [1, 2]
print(a * 3)
  • (A) Error
  • (B) [1, 2]
  • (C) [1, 2, 1, 2]
  • (D) [1, 2, 1, 2, 1, 2]
πŸ’¬ Discuss
βœ… Correct Answer: (D) [1, 2, 1, 2, 1, 2]
πŸ“Š Python
Q. What will be the output of the following code snippet?
Code:
example = ["Sunday", "Monday", "Tuesday", "Wednesday"];
del example[2]
print(example)
  • (A) ['Sunday', 'Monday', 'Tuesday', 'Wednesday']
  • (B) ['Sunday', 'Monday', 'Wednesday']
  • (C) ['Monday', 'Tuesday', 'Wednesday']
  • (D) ['Sunday', 'Monday', 'Tuesday']
πŸ’¬ Discuss
βœ… Correct Answer: (B) ['Sunday', 'Monday', 'Wednesday']
πŸ“Š Python
Q. What will be the type of the variable sorted_numbers in the below code snippet?
Code:
numbers = (4, 7, 19, 2, 89, 45, 72, 22)
sorted_numbers = sorted(numbers)
print(sorted_numbers)
  • (A) List
  • (B) Tuple
  • (C) String
  • (D) Int
πŸ’¬ Discuss
βœ… Correct Answer: (A) List
πŸ“Š Python
Q. What will be the output of the following code snippet?
Code:
numbers = (4, 7, 19, 2, 89, 45, 72, 22)
sorted_numbers = sorted(numbers)
even = lambda a: a % 2 == 0
even_numbers = filter(even, sorted_numbers)
print(type(even_numbers))
  • (A) filter
  • (B) int
  • (C) list
  • (D) tuple
πŸ’¬ Discuss
βœ… Correct Answer: (A) filter
πŸ“Š Python
Q. What will be the output of the following code snippet?
Code:
numbers = (4, 7, 19, 2, 89, 45, 72, 22)
sorted_numbers = sorted(numbers)
odd_numbers = [x for x in sorted_numbers if x % 2 != 0]
print(odd_numbers)
  • (A) [7, 19, 45, 89]
  • (B) [2, 4, 22, 72]
  • (C) [4, 7, 19, 2, 89, 45,72, 22]
  • (D) [2, 4, 7, 19, 22, 45, 72, 89]
πŸ’¬ Discuss
βœ… Correct Answer: (A) [7, 19, 45, 89]
πŸ“Š Python
Q. What will be the output of the following code snippet?
Code:
def is_even(number):
  message =  f"{number} is an even number" if number % 2 == 0 else  f"{number} is an odd number"
 return message
print(is_even(54))
  • (A) 54 is an even number
  • (B) 54 is an odd number
  • (C) number is an even number
  • (D) number is an odd number
πŸ’¬ Discuss
βœ… Correct Answer: (A) 54 is an even number
πŸ“Š Python
Q. What will be the output of the following code snippet?
Code:
dict1 = {'first' : 'sunday', 'second' : 'monday'}
dict2 = {1: 3, 2: 4}
dict1.update(dict2)
print(dict1)
  • (A) {'first': 'sunday', 'second': 'monday', 1: 3, 2: 4}
  • (B) {'first': 'sunday', 'second': 'monday'}
  • (C) {1: 3, 2: 4}
  • (D) None of the above.
πŸ’¬ Discuss
βœ… Correct Answer: (A) {'first': 'sunday', 'second': 'monday', 1: 3, 2: 4}
πŸ“Š Python
Q. What will be the output of the following code snippet?
Code:
s = {1, 2, 3, 3, 2, 4, 5, 5}
print(s)
  • (A) {1, 2, 3, 3, 2, 4, 5, 5}
  • (B) {1, 2, 3, 4, 5}
  • (C) None
  • (D) {1, 5}
πŸ’¬ Discuss
βœ… Correct Answer: (B) {1, 2, 3, 4, 5}
πŸ“Š Python
Q. What will be the output of the following code snippet?
Code:
a = {'Hello':'World', 'First': 1}
b = {val: k for k , val in a.items()}
print(b)
  • (A) {'Hello':'World', 'First': 1}
  • (B) {'World': 'Hello', 1: 'First'}
  • (C) Can be both A or B
  • (D) None of the above
πŸ’¬ Discuss
βœ… Correct Answer: (B) {'World': 'Hello', 1: 'First'}
πŸ“Š Python
Q. Which of the following functions converts date to corresponding time in Python?
  • (A) strptime()
  • (B) strftime()
  • (C) Both A and B
  • (D) None of the above
πŸ’¬ Discuss
βœ… Correct Answer: (A) strptime()