WorksheetsChapter 1: Statements Introduction
Total questions: 10
Worksheet time: 5mins
Programs typically execute how, with respect to statements?
One after another sequentially
Only upon user events
All at once concurrently
Randomly chosen per cycle
What does the end parameter in Python's print() function control?
Default text encoding used
Spacing between printed values
Order of arguments printed
String appended after the output
Which symbol is used as the assignment operator in Python?
colon :
double equals ==
single equals =
arrow ->
You run code: print "Hello" and see a caret under the H in Hello plus a message: SyntaxError: Missing parentheses in call to 'print'. What does the error message primarily tell you?
The version of the Python interpreter
The operating system details
The variable values at the crash
The type and location of the error
A programmer writes prints("Hello"). Which error will occur and why?
IndentationError because leading spaces exist
RuntimeError because function returns None
SyntaxError because quotes are mismatched
NameError because prints is undefined
Choose the most informative comment for a line that asks the user for meal choice.
# Input item1 and item2
# Get the user's preference
# Ask question to user
# Menu choice
Which statement about hash characters inside strings is correct?
Inside strings, # becomes a docstring
Inside strings, # starts a comment
Inside strings, # is regular text
Inside strings, # breaks execution
இந்த குறியீட்டின் வெளியீடு என்ன: print("Hello, World!")?
வணக்கம், உலகம்!
SyntaxError
None
TypeError
Which of the following is a valid way to define a function in Python?
myFunc() = function:
function myFunc():
def myFunc[]:
def myFunc():
What does the 'len()' function do in Python?
Returns the length of an object
Creates a new object
Converts an object to a list
Checks if an object is empty
