25th
Dec
Python MCQ

Python MCQ

  • Admin
  • 25th Dec, 2020
  • 943 Followers

Python MCQ Quiz

1) All keywords in Python are in _________

  • A. UPPER CASE
  • B. Capitalized
  • C. lower case
  • D. None of the mentioned

2) What is the return type of function id?

  • A. float
  • B. bool
  • C. int
  • D. dict

3) What will be the output of the following Python code?

  • A. Error
  • B. No output
  • C. t
  • D. f

4) Which of the following is incorrect?

  • A. x = 0b101
  • B. x = 0x4f5
  • C. x = 19023
  • D. x = 03964

5) Is Python case sensitive when dealing with identifiers?

  • A. Yes
  • B. No
Download Free : Python MCQ PDF

6) Which of the following expressions can be used to multiply a given number ‘a’ by 4?

  • A. a<<4
  • B. a>>2
  • C. a<<2
  • D. a>>4

7) Given a function that does not return any value, What value is thrown by default when executed in shell.

  • A. int
  • B. None
  • C. bool
  • D. void

8) Is Python case sensitive when dealing with identifiers?

  • A. yes
  • B. no
  • C. machine dependent
  • D. none of the mentioned

9) What does ~4 evaluate to?

  • A. -3
  • B. -4
  • C. -5
  • D. +3

10) Which of the following expressions results in an error?

  • A. int(‘1011’)
  • B. int(1011,2)
  • C. int(‘1011’,23)
  • D. int(1011)

11) Which of the following is not a keyword?

  • A. pass
  • B. assert
  • C. nonlocal
  • D. eval

12) What will be the output of the following Python code?

  • A. {‘san’, ‘foundry’}
  • B. san foundry
  • C. sanfoundry
  • D. Error

13) What is the type of inf?

  • A. Complex
  • B. Float
  • C. Boolean
  • D. Integer

14) Which of the following blocks will be executed whether an exception is thrown or not?

  • A. except
  • B. finally
  • C. else
  • D. assert

15) What is the answer to this expression, 22 % 3 is?

  • A. 7
  • B. 1
  • C. 5

16) What will be the output of the following Python code if the input entered is 6?

  • A. Bye (printed once)
  • B. Invalid (printed once)
  • C. No output
  • D. Bye (printed infinite number of times)

17) What is the output of print 0.1 + 0.2 == 0.3?

  • A. True
  • B. False
  • C. Machine dependen
  • D. Error

18) Which of the following expressions involves coercion when evaluated in Python?

  • A. 1.7 % 2
  • B. 4.7 – 1.5
  • C. 7.9 * 6.3
  • D. 3.4 + 4.6

19) Select the valid option for the following Output −

  • A. Canvas.Create_text(text= ''Hello! ''
  • B. Canvas.Create_text(30 , 40, text= ''Hello! '' ,filled= ''green ''
  • C. Canvas.Create_text(text= ''Hello! '' ,textcolor= ''Green''
  • D. Canvas.Create_text(30 , 40, text= ''Hello!''

20) Which of the following cannot be a variable?

  • A. __init__
  • B. in
  • C. it
  • D. on

21) Which of the following will run without errors?

  • A. round(45.8)
  • B. round(6352.898,2,5)
  • C. round()
  • D. round(7463.123,2,1)

22) Which of the following is not a complex number?

  • A. k = 2 + 3j
  • B. k = complex(2, 3)
  • C. k = 2 + 3l
  • D. k = 2 + 3J

23) Which of the following results in a SyntaxError?

  • A. ‘3\’
  • B. “He said, ‘Yes!'”
  • C. ‘”Once upon a time…”, she said.’
  • D. ”’That’s okay”’

24) Which of the following is not a standard exception in Python?

  • A. NameError
  • B. AssignmentError
  • C. IOError
  • D. ValueError

25) An exception is ____________

  • A. a standard module
  • B. a special function
  • C. a module
  • D. an object

26) Which one of the following has the same precedence level?

  • A. Addition and Subtraction
  • B. Multiplication, Division and Addition
  • C. Multiplication, Division, Addition and Subtraction
  • D. Addition and Multiplication

27) What is the maximum possible length of an identifier?

  • A. 79 characters
  • B. 31 characters
  • C. 63 characters
  • D. none of the mentioned

28) What will be the output of the following Python expression?

  • A. ‘0b10111’
  • B. ‘0b11111’
  • C. ‘0b11011’
  • D. ‘0b11101’

29) The expression shown below results in an error.

  • A. True
  • B. False

30) In order to store values in terms of key and value we use what core data type.

  • A. list
  • B. dictionary
  • C. class
  • D. tuple

31) Which of the following operators has its associativity from right to left?

  • A. +
  • B. **
  • C. %
  • D. //

32) Which of the following is invalid?

  • A. __str__ = 1
  • B. _a = 1
  • C. __a = 1
  • D. none of the mentioned

33) What will be the output of the following Python code snippet?

  • A. No output
  • B. Error
  • C. True
  • D. False

34) Which one of these is floor division?

  • A. //
  • B. /
  • C. %
  • D. None of the mentioned

35) Which of these in not a core data type?

  • A. Class
  • B. Lists
  • C. Tuples
  • D. Dictionary

36) Which of the following expressions results in an error?

  • A. float(‘10’)
  • B. int(’10.8’)
  • C. int(‘10’)
  • D. float(’10.8’)

37) What does 3 ^ 4 evaluate to?

  • A. 7
  • B. 12
  • C. 0.75
  • D. 81

38) Which of the following is an invalid variable?

  • A. foo
  • B. my_string_1
  • C. 1st_string
  • D. _

39) Which one of the following has the highest precedence in the expression?

  • A. Exponential
  • B. Multiplication
  • C. Parentheses
  • D. Addition

40) Which of the following is an invalid statement?

  • A. a b c = 1000 2000 3000
  • B. a,b,c = 1000, 2000, 3000
  • C. abc = 1,000,000
  • D. a_b_c = 1,000,000

Leave A Comment :

Valid name is required.

Valid name is required.

Valid email id is required.

Related MCQ/Quiz

01st
Dec
Laravel MCQ
01st
Dec
React JS MCQ
01st
Jan
AngularJs MCQ
01st
Jul
Node js MCQ
01st
Jul
Angular 2 MCQ
01st
Jul
JSON MCQ