WorksheetsPython Phase 1
Total questions: 30
Worksheet time: 3600secs
Which of the following variable names is invalid in Python?
data_value
3data
_data
DataValue
Which of the following is NOT a keyword in Python?
pass
break
def
print
What is the data type of the following variable?
<class 'int'>, <class 'int'>
<class 'str'>, <class 'int'>
<class 'str'>, <class 'str'>
<class 'int'>, <class 'str'>
What will be the output of the following code snippet?
3, 3
3, 3.33
3, 3.0
Error
What is the result of the following expression?
7
8
5
6
What will be the result of the following operation?
2
3
4
1
What will happen when the following code is executed?
print("Hello)
Hello will be printed.
An error will occur.
Nothing will be printed.
It will print None.
Identify the error in the following code:
Missing # for a comment
The variable x is not defined
Missing colon : after the if condition
Incorrect indentation after if
What will be printed by the following code snippet?
b is greater than 15
a is greater than b
b is not greater than 15
No output
What is the output of the following code?
lst = [1, 2, 3]
print(type(lst))
<class 'tuple'>
<class 'list'>
<class 'set'>
<class 'dict'>
What will be the output of the following code?
Positive
Zero
Negative
Error
Which of the following is the correct way to write a multi-line comment in Python?
# This is a multi-line comment
// This is a multi-line comment
/* This is a multi-line comment */
""" This is a multi-line comment """
Which of the following is not a valid comment syntax in Python?
# This is a single-line comment
''' This is a multi-line comment '''
" This is a comment "
""" This is also a valid multi-line comment """
Which of the following is not a valid Python data type?
int
float
long
dict
What will be the value of x after the following code executes?
x = 2 *3 ** 2
18
12
36
9
What will be the output of the following code?
print(type(10.5))
<class 'int'>
<class 'float'>
<class 'str'>
<class 'double'>
What will be the output of the following code?
3.14
3
4
Error
Which of the following statements is true about Python variable naming conventions?
Variables can start with a digit.
Variables can start with an underscore _.
Variables can contain spaces.
Variables can contain special characters like @ or %.
Which of the following statements will execute only if both conditions are True?
if a or b:
if a and b:
if not a:
if a + b:
What will be the output of the following code?
[1, 2, 3]
[1, 2, 3, 4]
None
Error
What will be the output of the following code?
[10, 20, 25, 30, 40]
[10, 25, 20, 30, 40]
[25, 10, 20, 30, 40]
[10, 20, 30, 25, 40]
What will be the output of the following code?
{1, 2, 3, 4, 3}
{1, 2, 3}
{1, 2, 3, 4}
{3, 4, 1, 2, 3}
What will be the output of the following code?
(1, 5, 3)
(1, 2, 3)
Error
[1, 5, 3]
What will be the output of the following code?
{1, 2, 3, 4, 5}
{3}
{1, 2, 4, 5}
Error
Which of the following operations is NOT valid for tuples?
tup[1]
len(tup)
tup[1:3]
tup.append(4)
What will be the result of the following code?
{'x': 10, 'y': 20}
{'x': 30, 'y': 20}
{'x': 40, 'y': 20}
{'x': 0, 'y': 20}
What will be the output of the following code?
"Hello Python"
"Python World"
"Hello World"
Error
What will be the output of the following code?
"Pyth"
"ytho"
"yth"
"ython"
What will be the result of the following code?
"Data"
"data"
Error
"Ddata"
What will be the output of the following code?
"Python Programming"
" Python Programming"
"Python Programming "
"PythonProgramming "
