๐ Computational Thinking & Programming-I Quiz 5 โ Expressions, Type Conversion & I/O (Class 11 CS)
Practice 20 CBSE Class 11 Computer Science (Code 083) MCQs on expressions, statements, type conversion, and input/output โ operator precedence, expression evaluation, explicit & implicit type conversion, and accepting/displaying data with input() and print().
Every expression and function result below has been verified by actually running it in Python. Tap any question to reveal the answer with a clear explanation.
๐ข Precedence
What is the precedence of operators in Python?
- Operators are evaluated from left to right
- Operators are evaluated from right to left
- Operators have equal precedence
- Operators have different precedence levels
Show Answer & Explanation
โ Answer: (d) Operators have different precedence levels
Python operators have different precedence levels โ for example, ** (exponent) is evaluated before * and /, which in turn are evaluated before + and -. Left-to-right evaluation only applies within operators of the same precedence level.
๐งฎ Expressions
Which of the following is an expression in Python?
- for i in range(5):
- x = 10
- print(โHello, World!โ)
- 5 + 3 * 2
Show Answer & Explanation
โ Answer: (d) 5 + 3 * 2
5 + 3 * 2 is a pure expression โ it combines values and operators to produce a single result (14) without any keyword or side effect. for ...: and x = 10 are statements, and while print() is technically a function call, it’s typically used as a statement performing an action rather than being valued for its result.
๐งฎ Expressions
How are expressions evaluated in Python?
- From left to right
- From right to left
- Based on operator precedence
- Randomly
Show Answer & Explanation
โ Answer: (c) Based on operator precedence
Expressions are evaluated based on operator precedence โ higher-precedence operators (like ** or those inside parentheses) are resolved before lower-precedence ones, regardless of their position in the expression.
๐ Type Conversion
What is type conversion in Python?
- Assigning a value to a variable
- Combining multiple values into a single value
- Converting one data type to another
- Evaluating an expression
Show Answer & Explanation
โ Answer: (c) Converting one data type to another
Type conversion means changing a value from one data type to another โ for example, turning the string "10" into the integer 10.
๐ Type Conversion
What is explicit type conversion in Python?
- Automatic conversion of data types
- Conversion of data types without specifying the target type
- Conversion of data types using built-in functions or methods
- Conversion of data types by Python interpreter
Show Answer & Explanation
โ Answer: (c) Conversion of data types using built-in functions or methods
Explicit type conversion (also called type casting) happens when the programmer deliberately calls a built-in function like int(), float(), or str() to convert a value.
๐ Type Conversion
What is implicit type conversion in Python?
- Automatic conversion of data types
- Conversion of data types without specifying the target type
- Conversion of data types using built-in functions or methods
- Conversion of data types by Python interpreter
Show Answer & Explanation
โ Answer: (a) Automatic conversion of data types
Implicit conversion happens automatically โ Python converts a value’s type behind the scenes when needed, without the programmer calling any function (e.g. an int automatically becoming a float during mixed-type arithmetic).
โจ๏ธ Input/Output
How can you accept data as input from the console in Python?
- Using the print() function
- Using the input() function
- Using the type() function
- Using the eval() function
Show Answer & Explanation
โ Answer: (b) Using the input() function
input() is the built-in function used to accept data typed by the user at the console, always returning it as a string.
โจ๏ธ Input/Output
What is the purpose of the input() function in Python?
- Display output on the console
- Convert data types
- Accept data as input from the user
- Evaluate an expression
Show Answer & Explanation
โ Answer: (c) Accept data as input from the user
The input() function’s job is simply to accept data as input from the user, pausing the program until they type something and press Enter.
โจ๏ธ Input/Output
How do you display output on the console in Python?
- Using the input() function
- Using the eval() function
- Using the print() function
- Using the type() function
Show Answer & Explanation
โ Answer: (c) Using the print() function
print() is the built-in function used to display output on the console.
๐ Type Conversion
What is the result of the expression int(โ10โ) in Python?
- โ10โ
- 10
- 0
- Error
Show Answer & Explanation
โ Answer: (b) 10
int("10") explicitly converts the string "10" into the actual integer 10 (no quotes โ it’s now a number, not text).
๐ Type Conversion
What is the result of the expression float(5) in Python?
- 5
- 0.0
- 5.0
- Error
Show Answer & Explanation
โ Answer: (c) 5.0
float(5) converts the integer 5 into its floating-point equivalent: 5.0.
๐ Type Conversion
What is the result of the expression str(42) in Python?
- 42
- โ42โ
- 0
- Error
Show Answer & Explanation
โ Answer: (b) โ42โ
str(42) converts the integer 42 into the string “42” โ shown with quotes here to indicate it’s now text, not a number.
๐ Type Conversion
What is the result of the expression bool(0) in Python?
- 0
- False
- True
- Error
Show Answer & Explanation
โ Answer: (b) False
In Python, 0 is considered โfalsyโ, so bool(0) evaluates to False. Every other non-zero number converts to True.
โจ๏ธ Input/Output
What is the result of the expression input(โEnter your name: โ) in Python?
- โEnter your name: โ
- None
- The user’s input as a string
- Error
Show Answer & Explanation
โ Answer: (c) The user’s input as a string
The text inside input() is just a prompt shown to the user. The expression itself evaluates to whatever the user actually types, always returned as a string โ even if they type numbers.
๐ Type Conversion
How do you convert a string to an integer in Python?
- Using the int() function
- Using the str() function
- Using the float() function
- Using the bool() function
Show Answer & Explanation
โ Answer: (a) Using the int() function
int() is the function to use โ for example, int("25") gives the integer 25. (It will raise a ValueError if the string isn’t a valid whole number.)
๐ข Precedence
Which of the following has the HIGHEST precedence in a Python expression?
- Addition (+)
- Multiplication (*)
- Exponentiation (**)
- Parentheses ()
Show Answer & Explanation
โ Answer: (d) Parentheses ()
Parentheses always have the highest precedence โ anything inside () is evaluated first, overriding the normal operator order. After that comes **, then *//, then +/-.
๐ Type Conversion
What is the result of the expression 5 + 2.5 in Python?
- 7 (as an integer)
- 7.5 (as a float)
- Error, since int and float can’t be added
- “7.5” (as a string)
Show Answer & Explanation
โ Answer: (b) 7.5 (as a float)
This is a classic example of implicit type conversion โ Python automatically converts the integer 5 into a float behind the scenes so it can be added to 2.5, giving 7.5 as a float.
โจ๏ธ Input/Output
What does eval() do in Python?
- Converts a string to an integer
- Evaluates a string as a Python expression and returns the result
- Prints a value to the console
- Declares a new variable
Show Answer & Explanation
โ Answer: (b) Evaluates a string as a Python expression and returns the result
eval() takes a string containing valid Python code and evaluates it as an expression, returning the result โ for example, eval("3 + 4") returns 7.
โจ๏ธ Input/Output
What does the statement num = int(input()) do in a single line?
- Reads input and keeps it as a string only
- Reads input from the user and converts it to an integer
- Converts a number to a string and displays it
- Always raises an error
Show Answer & Explanation
โ Answer: (b) Reads input from the user and converts it to an integer
This combines two steps: input() reads what the user types (as a string), and int() immediately converts that string into an integer โ a very common pattern for accepting numeric input.
โจ๏ธ Input/Output
Which method is commonly used with input() to accept multiple space-separated values on a single line?
- split()
- join()
- format()
- strip()
Show Answer & Explanation
โ Answer: (a) split()
input().split() is the standard pattern โ it reads one line of input and splits it into a list of separate values wherever there’s whitespace, letting you accept multiple inputs at once.
