MCQ of Python | Python MCQ with Answer

1. Which type of programming does python support?

a. Object oriented programming

b. Structured programming

c. Functional Programming

d. All of the mentioned

2. Who developed Python Programming Language?

a. Wick van Rossum

b. Rasmus Lerdorf

c. Guido van Rossum

d. Sergey Brin

3. Python is a:

a. Low-level language

b. High-level language

c. Middle-level language

d. Machine-level language

4. Which of the following is the correct extension of the Python file?

a. .python

b. .pl

c. .py

d. .p

5. In which language is Python written?

a. C

b. C++

c. Java

d. None of these

6. Which one is NOT a legal variable name?

a. my-var  

b. _myvar

c. Myvar

d. my_var

7. When a new value is stored in a variable, its previous value gets _______________.

a. Accepted

b. Overwritten

c. Overlapped

d. Overview

8. What data type would you use to store a whole number in Python?

a. Int

b. Float

c. Str

d. Bool

9. What will be the data type of the variable x after this assignment:

x = 3.5?

a. Int

b. Float

c. Str

d. complex

10. Which function in Python is used to display data as output?

a. display()

b. print()

c. show()

d. output()

11. Python has __________ function for taking user input.

a. display()

b. print()

c. show()

d. input()

12. All keywords in Python are in _________

a. Capitalized

b. lower case

c. UPPER CASE

d. None of the mentioned

Explanation: Most keywords are in lowercase, but some like True, False, and None are capitalized.

13. Which of the following character is used to give single-line comments in Python?

a. //

b. #

c. !

d. /*

14. Which of the following is a valid Python comment?

a. <!−− −−>

b. /* */

c. #

d. //

15. How do you insert COMMENTS in Python code?

a. #This is a comment  

b. /*This is a comment*/

c. //This is a comment

d. None of these

16. Which of the following is used to define a block of code in Python language?

a. Indentation

b. Key

c. Brackets

d. All of the mentioned

17. What is the purpose of the end parameter in the print() function?

a. To add a space at the end

b. To end the script

c. To specify the string appended after the last value

d. To break the line

18. What does the sep parameter do in the print() function?

a. Separates lines

b. Specifies separator between values

c. Separates syntax errors

d. None of these

19. What will be the output of

print(“Python”, “Programming”, sep=”-“)

  1. Python-Programming
  2. Python Programming
  3. PythonProgramming
  4. Python,Programming

20. What is the output of

print(“Hello”, end=’@’);
print(“World”)

  1. HelloWorld
  2. Hello@World
  3. Hello World
  4. Hello@ World

21. Identify the error:

print(“Hello World!”))

  1. Missing quotation marks
  2. Extra parenthesis
  3. Missing parenthesis
  4. No error

22. What is a correct syntax to output “Hello World” in Python?

a. print(“Hello World”)

b. echo “Hello World”

c. echo(“Hello World”)

d. p(“Hello World”)

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

a. |

b. //

c. /

d. %

24. ___________ operator is used to assign value of an expression to a variable.

a. Relational

b. Logical

c. Assignment

d. None of the above

25. ___________ operators are used to check conditions or comparison of operands.

a. Relational

b. Logical

c. Assignment

d. None of the above

26. Which operator can be used to compare two values?

a. ==    

b. =>

c. < 

d. <> 

27. Which method can be used to return a string in upper case letters?

a. upper()    

b. uppercase()

c. upperCase()

d. toUpperCase()

28. The _______ statement is used for decision making.

a. For

b. While

c. If

d. None of the above

29. How do you start writing an if statement in Python?

a. if x > y:  

b. if (x > y)

c. if x > y then:

d. if x>y

30. _______ statement can be used to iterate over a range of values or a sequence.

a.    For

b.   If

c.    Both of the above

d.   None of the above

31. How do you start writing a for loop in Python?

a. for x in y:  

b. for x > y:

c. for each x in y:

d. for (x > y)

32. Which statement is used to stop a loop?

a. break  

b. return

c. exit

d. stop

33. How do you start writing a while loop in Python?

a. while (x > y)  

b. while x > y {

c. while x > y:  

d. x > y while {

34. Which of the following is a mutable data type in Python?

a. String

b. Tuple

c. List

d. Integer

35. Which collection is ordered, changeable, and allows duplicate members?

a. LIST    

b. TUPLE

c. DICTIONARY

d. SET

36. Which of these collections defines a LIST?

a. [“apple”, “banana”, “cherry”]    

b. (“apple”, “banana”, “cherry”)

c. {“name”: “apple”, “color”: “green”}

d. {“apple”, “banana”, “cherry”}

37. Which of the following is an immutable data type?

a. Lists

b. Dictionaries

c. Tuples

d. Sets

38. Which of these collections defines a TUPLE?

a. (“apple”, “banana”, “cherry”)    

b. {“apple”, “banana”, “cherry”}

c. [“apple”, “banana”, “cherry”]

d. {“name”: “apple”, “color”: “green”}

39. Which of the following is a Python tuple?

a. {1, 2, 3}

b. {}

c. [1, 2, 3]

d. (1, 2, 3)

40. Standard mapping data type in Python called ____________

a. Lists

b. Dictionaries

c. Tuples

d. Sets

41. Which of these collections defines a DICTIONARY?

a. {“name”: “apple”, “color”: “green”}    

b. {“apple”, “banana”, “cherry”}

c. [“apple”, “banana”, “cherry”]

d. (“apple”, “banana”, “cherry”)

42. Which of the following statements is used to create an empty set in Python?

a. ( )

b. [ ]

c. { }

d. set()

43. Which collection does not allow duplicate members?

a. SET    

b. LIST

c. TUPLE

d. None of these

44. Which of these collections defines a SET?

a. {“apple”, “banana”, “cherry”}    

b. (“apple”, “banana”, “cherry”)

c. [“apple”, “banana”, “cherry”]

d. {“name”: “apple”, “color”: “green”}

45. Which keyword is used for function in Python language?

a. Function

b. Def

c. Fun

d. Define

46. Which one of the following is the use of function in python?

a. Functions don’t provide better modularity for your application

b. you can’t also create your own functions

c. Functions are reusable pieces of programs

d. All of the mentioned

47. What are the two main types of functions in Python?

a. System function

b. Custom function

c. Built-in function & User defined function

d. User function

48. Python has many predefined functions called __________.

a. System function

b. Custom function

c. Built-in function

d. User defined function

49. User defined function uses ___________ keyword.

a. Function

b. Def

c. Fun

d. Define

50. What is the correct way to create a function in Python?

a. def myFunction():  

b. function myfunction():

c. create myFunction():

d.   None of the above

7 thoughts on “MCQ of Python | Python MCQ with Answer”

  1. SocialMediaGirls You’re so awesome! I don’t believe I have read a single thing like that before. So great to find someone with some original thoughts on this topic. Really.. thank you for starting this up. This website is something that is needed on the internet, someone with a little originality!

    Reply

Leave a Comment