Computer Science Exam MCQs - Part 3
21. Which of the following is NOT a valid data type in Python?
a) integer
b) float
c) Boolean
d) character
22. What is the operator used for string concatenation in Python?
a) +
b) *
c) &
d) /
23. Which keyword is used to define a function in Python?
a) define
b) create
c) def
d) function
24. Python is an:
a) Compiled language
b) Interpreted language
c) Assembly language
d) Machine language
25. What is the indentation style used in Python to define code blocks?
a) Braces ({})
b) Semicolons (;)
c) Indentation (spaces or tabs)
d) Keywords (like if, else)
26. Which of the following is the correct way to access the second element of a list in Python?
a) list[0]
b) list(1)
c) list[1]
d) list.get(1)
27. What is the output of the following Python code: `print(5 + 2 * 3)`
a) 11
b) 15
c) 6
d) Error
28. Which loop iterates over each element in a sequence (like a list) in Python?
a) while loop
b) for loop
c) do-while loop
d) repeat loop
29. What is the purpose of the `pass` keyword in Python?
a) To define a variable
b) To define a function body (placeholder)
c) To skip a code block
d) To print a blank line
30. How do you import a Python module named `math`?
a) include math.py
b) use math();
c) import math
d) require math
21- d) character
22- a) +
23- c) def
24- b) Interpreted language
25- c) Indentation (spaces or tabs)
26- c) list[1]
27- a) 11
28- b) for loop
29- b) To define a function body (placeholder)
30- c) import math
Comments
Post a Comment
Write something to CodeWithAbdur!