WorksheetsPython 2
Total questions: 23
Worksheet time: 11mins
The correct way to convert user input is:
birth_year = number(input())
birth_year = int(input())
birth_year = (input(int))
birth_year = int(input)
What is the output for the following code?
100
50
20
130
What is the purpose of variables in Python?
Variables in Python are used to store data values for later use.
Variables in Python are used for decoration purposes only.
Variables in Python are used to perform mathematical operations.
Variables in Python are used to confuse the programmer.
How do you declare a variable in Python?
variable_name = value
variable_name : value
variable_name = value =
value = variable_name
What are the different types of conditional statements in Python?
when
unless
otherwise
if, elif, else
What is the syntax for an if statement in Python?
if (condition) then
if condition:
if (condition):
if condition then:
How do you add comments in Python code?
Use the '#' symbol to add comments in Python code.
Use the '/* */' symbols to add comments in Python code.
Use the '//' symbol to add comments in Java code.
Use the '//' symbol to add comments in Python code.
What will be the output of the following code?
A) Greater
B) Smaller
C) Error
D) None
What will be the output of the following code?
A) Greater
B) Smaller
C) Error
D) None
What will be the output of the following code?
A) Greater
B) Smaller
C) Equal
D) Error
What will be the output of the following code?
A) Greater
B) Smaller
C) Equal
D) Error
What will be the output of the following code?
A) Yes
B) No
C) Error
D) None
What will be the output of the following code?
A) Yes
B) No
C) Error
D) None
What will be the output of the following code?
A) Yes
B) No
C) Error
D) None
What will be the output of the following code?
A) Greater
B) Equal
C) Smaller
D) Error
What will be the output of the following code?
A) Both True
B) Only x is True
C) Both False
D) Error
What will be the output of the following code?
A) x is True, y is False
B) Both True
C) x is False
D) Error
What will be the output of the following code?
A) Negative
B) Zero
C) Positive
D) Error
What will be the output of the following code?
A) Negative
B) Zero
C) Positive
D) Error
What will be the output of the following code?
A) Negative
B) Zero
C) Positive
D) Error
What will be the output of the following code?
A) Even
B) Odd
C) Error
D) None
What will be the output of the following code?
A) Even
B) Odd
C) Error
D) None
