Skip to content

Introduction to Python MCQ

Introduction to Python MCQ

MCQ

Chapter 2: Introduction to Python

40 Multiple Choice Questions (MCQs)


1. Python is a:

(a) Low-level language

(b) High-level language

(c) Machine language

(d) Assembly language

Answer: (b) High-level language


2. Python was developed by:

(a) Dennis Ritchie

(b) James Gosling

(c) Guido van Rossum

(d) Bjarne Stroustrup

Answer: (c) Guido van Rossum


3. Python was first released in:

(a) 1989

(b) 1991

(c) 1995

(d) 2000

Answer: (b) 1991


4. Python is an:

(a) Interpreted language

(b) Compiled language only

(c) Machine language

(d) Assembly language

Answer: (a) Interpreted language


5. Which symbol is used for comments in Python?

(a) //

(b) /* */

(c) #

(d) %

Answer: (c) #


6. Which of the following is a valid Python identifier?

(a) 1name

(b) my-name

(c) my_name

(d) class

Answer: (c) my_name


7. Python keywords are:

(a) User-defined words

(b) Reserved words

(c) Variable names

(d) Function names

Answer: (b) Reserved words


8. Which function is used to display output in Python?

(a) input()

(b) display()

(c) print()

(d) show()

Answer: (c) print()


9. Which function is used to take input from the user?

(a) get()

(b) scan()

(c) input()

(d) read()

Answer: (c) input()


10. Python is:

(a) Case-sensitive

(b) Case-insensitive

(c) Both

(d) None

Answer: (a) Case-sensitive

```

11. Which of the following is a valid variable name?

(a) student_name

(b) student-name

(c) 2student

(d) class

Answer: (a) student_name


12. Which data type represents whole numbers?

(a) float

(b) int

(c) str

(d) bool

Answer: (b) int


13. Which data type represents decimal numbers?

(a) int

(b) float

(c) str

(d) bool

Answer: (b) float


14. Which data type represents text?

(a) int

(b) float

(c) str

(d) bool

Answer: (c) str


15. What is the output of:

print(type(10))

(a) int

(b) <class 'int'>

(c) integer

(d) number

Answer: (b) <class 'int'>


16. Which operator is used for addition?

(a) *

(b) /

(c) +

(d) %

Answer: (c) +


17. Which operator is used for exponentiation?

(a) ^

(b) **

(c) //

(d) %

Answer: (b) **


18. What is the output of:

print(10//3)

(a) 3.33

(b) 3

(c) 4

(d) 1

Answer: (b) 3


19. What is the output of:

print(10%3)

(a) 3

(b) 0

(c) 1

(d) 10

Answer: (c) 1


20. Which operator is used for assignment?

(a) ==

(b) =

(c) !=

(d) <=

Answer: (b) =

```

21. Which operator checks equality?

(a) =

(b) ==

(c) !=

(d) <>

Answer: (b) ==


22. What is the output of:

print(5 > 3)

(a) True

(b) False

(c) Error

(d) 5

Answer: (a) True


23. Which data type has only two values: True and False?

(a) int

(b) str

(c) float

(d) bool

Answer: (d) bool


24. Which keyword is used to make decisions in Python?

(a) for

(b) if

(c) while

(d) break

Answer: (b) if


25. Which keyword is used with if for an alternative condition?

(a) else

(b) then

(c) switch

(d) case

Answer: (a) else


26. Which loop is used when the number of iterations is known?

(a) while

(b) for

(c) do-while

(d) repeat

Answer: (b) for


27. Which loop is used when the number of iterations is unknown?

(a) for

(b) while

(c) repeat

(d) foreach

Answer: (b) while


28. Which statement is used to terminate a loop?

(a) continue

(b) skip

(c) break

(d) exit

Answer: (c) break


29. Which statement skips the current iteration?

(a) break

(b) continue

(c) pass

(d) return

Answer: (b) continue


30. What is the output of:

print("Hello" * 3)

(a) HelloHelloHello

(b) Hello 3

(c) Error

(d) Hello*3

Answer: (a) HelloHelloHello


31. Which symbol is used to define a block in Python?

(a) {}

(b) []

(c) Indentation

(d) ()

Answer: (c) Indentation


32. Which of the following is a Python keyword?

(a) define

(b) function

(c) while

(d) repeat

Answer: (c) while


33. What is the output of:

x = 5
print(x)
    

(a) x

(b) 5

(c) Error

(d) None

Answer: (b) 5


34. Which function converts a string to an integer?

(a) float()

(b) str()

(c) int()

(d) bool()

Answer: (c) int()


35. Which function converts a number to a string?

(a) str()

(b) int()

(c) float()

(d) chr()

Answer: (a) str()


36. What is the output of:

print(len("Python"))

(a) 5

(b) 6

(c) 7

(d) Error

Answer: (b) 6


37. Which of the following is used to store multiple values?

(a) Variable

(b) List

(c) Integer

(d) String

Answer: (b) List


38. What is the index of the first element in a Python list?

(a) 1

(b) -1

(c) 0

(d) 2

Answer: (c) 0


39. Which bracket is used to create a list?

(a) ()

(b) []

(c) {}

(d) <>

Answer: (b) []


40. What will be the output of:

print("Python"[0])

(a) P

(b) y

(c) Python

(d) Error

Answer: (a) P