← Back to Subject
Python Programming • MCQ • Input and Output
Most Important 30 Objective Question - Input and Output
Q1. Which of the following is a valid identifier in Python?

A) 2name
B) my_name
C) class
D) first-name

Answer: B) my_name

Explanation:
Identifiers are names used for variables, functions, etc. They cannot start with a digit, cannot use special symbols like (-), and cannot be reserved keywords.

Q2. Which of the following is a Python keyword?

A) value
B) while
C) number
D) total

Answer: B) while

Explanation:
while is a reserved keyword used for loops. Keywords have special meaning and cannot be used as variable names.

Q3. Python is a ______ typed language.

A) Weakly
B) Dynamically
C) Manually
D) None

Answer: B) Dynamically

Explanation:
Python is dynamically typed, meaning the variable type is decided during runtime automatically.

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

A) print()
B) input()
C) scanf()
D) get()

Answer: B) input()

Explanation:
input() is used to read input from the keyboard in Python.

Q5. Which function is used to display output?

A) output()
B) display()
C) print()
D) show()

Answer: C) print()

Explanation:
print() is the standard function used to display output on the screen.

Q6. Which of the following is NOT a basic data type in Python?

A) int
B) float
C) real
D) str

Answer: C) real

Explanation:
Python uses int, float, str, bool, etc. There is no built-in type called real.

Q7. What is the output of type(10)?

A) int
B) float
C) str
D) bool

Answer: A) int

Explanation:
type() tells the datatype of a value. Since 10 is an integer, output is int.

Q8. Which symbol is used for comments in Python?

A) //
B)
C) #
D) /* */

Answer: C) #

Explanation:
Single-line comments start with # in Python.

Q9. Which operator is used for exponentiation?

A) ^
B) **
C) //
D) %%

**Answer: B) **

Explanation:
** is used to calculate powers in Python. Example: 2**3 = 8

Q10. Which operator is used for floor division?

A) /
B) //
C) %
D) **

Answer: B) //

Explanation:
// gives quotient without decimal part.

Example: 10 // 3 = 3

Q11. What is the result of 10 % 3?

A) 3
B) 1
C) 0
D) 10

Answer: B) 1

Explanation:
% gives remainder after division.

Q12. Which operator checks equality?

A) =
B) ==
C) !=
D) <=

Answer: B) ==

Explanation:
== compares two values. = is assignment operator.

Q13. Which operator is used for assignment?

A) ==
B) =
C) !=
D) >=

Answer: B) =

Explanation:
= is used to assign values to variables.

Q14. What is the output of 3 > 2 and 5 > 1?

A) True
B) False
C) Error
D) None

Answer: A) True

Explanation:
Both conditions are true, so result is True.

Q15. Which logical operator means “OR”?

A) and
B) or
C) not
D) xor

Answer: B) or

Explanation:
or returns True if at least one condition is true.

Q16. Which function converts string to integer?

A) float()
B) int()
C) str()
D) bool()

Answer: B) int()

Explanation:
int() converts values into integer type.

Q17. What is indentation in Python?

A) Decoration
B) Space before code line
C) Loop
D) Comment

Answer: B) Space before code line

Explanation:
Indentation is mandatory in Python and defines code blocks.

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

A) student_name
B) student-name
C) 1student
D) class

Answer: A) student_name

Explanation:
Underscore is allowed, but hyphen, digits at start, and keywords are not allowed.

Q19. What is the output of type("100")?

A) int
B) str
C) float
D) bool

Answer: B) str

Explanation:
Anything inside quotes is treated as string.

Q20. Which operator checks object identity?

A) ==
B) =
C) is
D) in

Answer: C) is

Explanation:
is checks whether two variables refer to the same object.

Q21. Python is a ______ typed language.

A) Weak
B) Strongly
C) None
D) Static

Answer: B) Strongly

Explanation:
Python is strongly typed, meaning automatic unsafe conversion does not happen.

Q22. Which function converts number to string?

A) str()
B) int()
C) float()
D) type()

Answer: A) str()

Explanation:
str() converts values into string format.

Q23. What is the output of print("Hello")?

A) "Hello"
B) Hello
C) Error
D) None

Answer: B) Hello

Explanation:
print() displays the content without quotation marks.

Q24. Which operator has highest precedence?

A) +
B) *
C) **
D) -

**Answer: C) **

Explanation:
Exponent operator ** has higher precedence than multiplication and addition.

Q25. Which bracket is used in print()?

A) {}
B) []
C) ()
D) <>

Answer: C) ()

Explanation:
Functions in Python use parentheses.

Q26. Which value represents Boolean false?

A) True
B) 1
C) False
D) Yes

Answer: C) False

Explanation:
Python Boolean values are True and False.

Q27. What is the output of 5 + 2 * 3?

A) 21
B) 11
C) 15
D) 7

Answer: B) 11

Explanation:
Multiplication happens first due to precedence.

2*3 = 6, then 5+6 = 11

Q28. Which statement is true for Python?

A) Case-insensitive
B) Case-sensitive
C) No variables
D) No loops

Answer: B) Case-sensitive

Explanation:
Name and name are treated as different variables.

Q29. Which datatype stores decimal values?

A) int
B) float
C) str
D) bool

Answer: B) float

Explanation:
Decimal numbers are stored using float.

Q30. Which of the following is correct?

A) x = "10" + 5
B) x = int("10") + 5
C) x = 10 + "5"
D) Both A and C

Answer: B) x = int("10") + 5

Explanation:
String and integer cannot be directly added. First convert string to integer using int().
Google AdSense Ad Placement Here 📢