Q. What will be the output of the following Python code snippet if x=1?

Code:
x<<2
  • (A) 4
  • (B) 2
  • (C) 1
  • (D) 8
πŸ’¬ Discuss
βœ… Correct Answer: (A) 4

Q. What does pip stand for python?

  • (A) unlimited length
  • (B) all private members must have leading and trailing underscores
  • (C) Preferred Installer Program
  • (D) none
πŸ’¬ Discuss
βœ… Correct Answer: (C) Preferred Installer Program

Q. Which of the following is true for variable names in Python?

  • (A) underscore and ampersand are the only two special characters allowed
  • (B) unlimited length
  • (C) all private members must have leading and trailing underscores
  • (D) none
πŸ’¬ Discuss
βœ… Correct Answer: (B) unlimited length

Q. What are the values of the following Python expressions?

Code:
2**(3**2)
 (2**3)**2
 2**3**2
  • (A) 512, 64, 512
  • (B) 512, 512, 512
  • (C) 64, 512, 64
  • (D) 64, 64, 64
πŸ’¬ Discuss
βœ… Correct Answer: (A) 512, 64, 512

Q. Which of the following is the truncation division operator in Python?

  • (A) |
  • (B) //
  • (C) /
  • (D) %
πŸ’¬ Discuss
βœ… Correct Answer: (B) //

Q. What will be the output of the following Python code?

Code:
l=[1, 0, 2, 0, 'hello', '', []]
list(filter(bool, l))
  • (A) [1, 0, 2, ‘hello’, ”, []]
  • (B) Error
  • (C) [1, 2, ‘hello’]
  • (D) [1, 0, 2, 0, ‘hello’, ”, []]
πŸ’¬ Discuss
βœ… Correct Answer: (C) [1, 2, ‘hello’]

Q. Which of the following functions is a built-in function in python?

  • (A) factorial()
  • (B) print()
  • (C) seed()
  • (D) sqrt()
πŸ’¬ Discuss
βœ… Correct Answer: (B) print()

Q. Which of the following is the use of id() function in python?

  • (A) Every object doesn’t have a unique id
  • (B) Id returns the identity of the object
  • (C) All of the mentioned
  • (D) None
πŸ’¬ Discuss
βœ… Correct Answer: (B) Id returns the identity of the object

Q. The following python program can work with ____ parameters.

Code:
def f(x):
    def f1(*args, **kwargs):
           print("Sanfoundry")
           return x(*args, **kwargs)
    return f1
  • (A) any number of
  • (B) 0
  • (C) 1
  • (D) 2
πŸ’¬ Discuss
βœ… Correct Answer: (A) any number of

Q. What will be the output of the following Python function?

Code:
min(max(False,-3,-4), 2,7)
  • (A) -4
  • (B) -3
  • (C) 2
  • (D) False
πŸ’¬ Discuss
βœ… Correct Answer: (D) False