A.
MULTIPLE CHOICE QUESTIONS
1. Which of the following is the output of this code: print(50/5)?
a. 10
b. 55
c. 50/5
d. Syntax error
Answer: a. 10
Explanation : The expression inside the print command is the sum of two
[Link] print command will calculate the value of 50/5, which is 10.
2. Which of the following is the output of this code: print(“7” + ”6”)?
a. 13
b. 76
c. 7+6
d. Syntax error
Answer: b. 76
Explanation : The expression inside the print command is not the sum of two
numbers, but two strings. The addition of two strings is concatenation, so the
print command will print 76.
3. Which of the following is a valid Python code to display “Hello World”?
a. Print“Hello World”
b. print(Hello World)
c. print(“Hello World”)
d. print{“Hello World”}
Answer: c. print(“Hello World”)
Explanation : The print command’s syntax , to display text, is : print(“<text to be
displayed”).
4. What will be the output of the code: print(“11*7”)
a. 18
b. 77
c. 11*7
d. “11*7”
Answer: c. 11*7
Explanation : The print command’s syntax , to display text, is : print(“<text to be
displayed”). Here, as 11*7 is enclosed in(“ “), it will be treated as text, and not a
mathematical term.
5. Observe the following Python code: print(“Hello\nHow are you?”)
What will be the output?
a. Hello
How are you?
b. HelloHow are you?
c. Hello\nHow are you?
d. “Hello\nHow are you?”
Answer: a. Hello
How are you?
Explanation : If we use “\n” in the print statement, then the expression after
“\n” is printed in the next line. Thus, print(“Hello\nHow are you?”) will display
“Hello” in the first line, and “How are you?” in the next line.
B. FILL IN THE BLANKS
1. When a data is kept inside double quotes, Python interprets it as string.
2. In interactive mode, you can see the result after writing every line of Python
code.
3. The text written after # sign is interpreted as a single line comment.
4. To write multiple line comments a pair of triple quotes is used.
5. \n adds a line break in the text in the print function.
C. DESCRIPTIVE QUESTIONS
1. Write the syntax for printing a joke: “Why don't scientists trust atoms?
Because they make up everything!” but before this write the following
multiline comment:
This is
a simple program
for showing simple jokes
“””This is
a simple program
for showing simple jokes”””
print(“Why don't scientists trust atoms? Because they make up everything!”)
2. Write down the outputs of the given commands:
a. print(My name is Mira…)
b. print(“My name is Mira…”)
c. print(‘My name is “Mira”’)
In case of b, the program will simply print “My name is Mira…”. In the case of a and
c, the output will be a Syntax error message.
3. Look at the following code and explain what is wrong with it:
“ # This is a simple Python code for demonstrating use of print function ”
Print( “ I am a fast bowler in my cricket team” )
print( “ The maximum wickets I have taken in a single match is ” + 7 )
In the first line of the code, the comment is in quotes. This is an error. In the second
line, the ‘print’ command has a capital P. In the third line, the addition is between a
string and an integer.
4. Write down the syntaxes for the following:
a. Printing a text in multiple lines
b. Printing addition of two numbers
print(“<Line1 of text>\n<<Line2 of text>)
print(<1st number>+<2nd number>)
5. Explain why the following code shows an error:
print(10+“9”)
When the addition operator is used with two numerical values, and the
operation is used with print, the output is the sum. When it is done with two
strings, the output is the two strings combined into one. But a string and a
numerical value cannot be added.
6. Why do we need comments in our code?
Comments in code explain or provide context about the code's functionality.
They enhance code readability and facilitate effective communication among
the various coders working on the same code. This aids in understanding,
maintaining, and collaborating on the code.
D. HOTS (HIGHER ORDER THINKING SKILLS) QUESTIONS
1. Write the code for calculating the following: 36 ÷ 6 x 3 + 22 - (3 + 5)
The code will be : print((36/6)*3+2**2-(3+5))
E. IMAGE-BASED QUESTIONS
1. Look at the snapshots given below, predict the outputs:
Hello World
An error message
No output, as it is a comment
7.0
F. UPSKILL
1. Look at the following code and its output:
Code Result
Hello World
Experiment with the ‘end’ parameter in the print function, and find out
why it is used.
2. Look at the following code and its output:
Code Result
one-two-three
Experiment with the ‘sep’ parameter in the print function, and find out
why it is used.