Study Key A Content Processing Service for Students and Teachers, for Study and Evaluation
A Content Processing Service for Students and Teachers, for Study and Evaluation

Exercise 2 Solutions · Unit 2: Python Programming

8 reading sections · 19 MCQs · 8 short · 5 long questions

All 32 Ex 2 22

Exercise 2 — Exercise 2: MCQs, short and long questions

Ex 2 · QMCQ 1 MCQ1 mark
An action needed during Python installation to run from the command line easily:
(a) Uncheck "Add Python to PATH"
(b) Choose a different IDE
(c) Check "Add Python to PATH"
(d) Install only the IDE
⚑ Report a mistake
Ex 2 · QMCQ 2 MCQ1 mark
A valid variable name in Python is:
(a) variable1
(b) 1variable
(c) variable-name
(d) variable name
⚑ Report a mistake
Ex 2 · QMCQ 3 MCQ1 mark
Output of the following piece of code is: ``` age = 25 print(" Age : ", age) ```
(a) Age: 25
(b) 25
(c) Age
(d) age
⚑ Report a mistake
Ex 2 · QMCQ 4 MCQ1 mark
The operator used for exponentiation in Python is:
(a) `*`
(b) `**`
(c) `//`
(d) `/`
⚑ Report a mistake
Ex 2 · QMCQ 5 MCQ1 mark
A loop used to iterate over a collection such as lists is:
(a) while
(b) for
(c) do-while
(d) repeat
⚑ Report a mistake
Ex 2 · QMCQ 6 MCQ1 mark
A range() function used to generate a sequence of numbers:
(a) Generates a list of numbers
(b) Creates a sequence of numbers
(c) Calculates the sum of numbers
(d) Prints a range of numbers
⚑ Report a mistake
Ex 2 · QMCQ 7 MCQ1 mark
A keyword used to define a function in Python:
(a) define
(b) function
(c) def
(d) func
⚑ Report a mistake
Ex 2 · QMCQ 8 MCQ1 mark
The Output of the following code is: ``` temperature, humidity, wind_speed = 25, 60, 15 print("Hot and humid" if temperature > 30 and humidity > 50 else "Warm and breezy" if temperature == 25 and wind_speed > 10 else "Cool and dry" if temperature < 20 and humidity < 30 else "Moderate") ```
(a) Hot
(b) Warm
(c) Cool
(d) Nothing
⚑ Report a mistake
Ex 2 · QMCQ 9 MCQ1 mark
The operation used to combine two lists in Python:
(a) combine()
(b) concat()
(c) +
(d) merge()
⚑ Report a mistake
Ex 2 · QShort 1 Short2 marks
Explain the purpose of using comments in Python code.
⚑ Report a mistake
Ex 2 · QShort 2 Short2 marks
Describe the difference between integer and float data types in Python. Provide an example of each.
⚑ Report a mistake
Ex 2 · QShort 3 Short2 marks
Define operator precedence and give an example of an expression where operator precedence affects the result.
⚑ Report a mistake
Ex 2 · QShort 4 Short2 marks
How does the short-hand if-else statement differ from the regular if-else statement?
⚑ Report a mistake
Ex 2 · QShort 5 Short2 marks
Explain the use of the range() function in a for loop.
⚑ Report a mistake
Ex 2 · QShort 6 Short2 marks
Explain how default parameters work in Python functions.
⚑ Report a mistake
Ex 2 · QShort 7 Short2 marks
Explain why modular programming is useful in Python.
⚑ Report a mistake
Ex 2 · QShort 8 Short2 marks
Explain the difference between a class and an object in Python.
⚑ Report a mistake
Ex 2 · QLong 1 LongNumerical5 marks
Evaluate the following Python expressions. ``` (a) (18 / 3 + 4 ** 2) - (2 * (7 - 3)) / (9 % 4) (b) (25 + 3 * 4 ** 2 - 6) / (2 ** 3 + 1) - 7 (c) (12 + 6 * (5 - 2)) ** 2 / ((4 ** 2 - 7) + 10) (d) 45 / (2 ** 2 + 3 * 4) + 8 * (7 - 3) ```
⚑ Report a mistake
Ex 2 · QLong 2 Long5 marks
Translate the following mathematical expressions to Python syntax. (a) 5 × (3 + 2²) ÷ (6 − 2 × 3) (written in the book as a fraction: 5 × (3 + 2²) over 6 − 2 × 3) (b) 7 + 2²
⚑ Report a mistake
Ex 2 · QLong 4 Long5 marks
Explain the concept of variables in Python.
⚑ Report a mistake
Ex 2 · QLong 5 LongProgram5 marks
Write a Python program that takes a number as input and checks whether it is positive, negative, or zero using an if-elif-else statement.
⚑ Report a mistake
Ex 2 · QLong 6 LongProgram5 marks
Write a Python program using a while loop that prints all the odd numbers between 1 and 100. Also, count and print the total number of odd numbers.
⚑ Report a mistake
Something went wrong. Reload ✕