WorksheetsPython Essentials 1 - Exam
Total questions: 40
Worksheet time: 18mins
How many element does the lst list contain?
zero
three
one
two
What is the output of the following piece of code if the user enters two lines containing 3 and 2 respectively?
3
0
2
1
Which of the following snippet shows the correct way of handling multiple exceptions in a single except clause?
Which of the following lines correctly invoke the function defined below?
(Select TWO answers)
fun (b=1)
fun (b=0, a=1)
fun (0,1,2)
fun(0)
Assuming that my_tuple is a correctly created tuple, the fact that tuples are immutable means that the following instructions:
may be illegal if the tuple contains strings
can be executed if and only if the tuple contains at least two elements
is illegal
is fully correct
Which of the following variable names are ILLEGAL and will cause the SyntaxError exception?
(Select TWO answer)
In
for
in
What is the output of the following snippet?
(4,)
44
(4)
4
Which of the following is the correct extension of the Python file?
a) .python
b) .pl
c) .py
d) .p
Which of the following character is used to give single-line comments in Python?
a) //
b) #
c) !
d) /*
What is the greater than symbol:
(a)
What is the output of the following snippet if the user enters two lines containing 3 and 6 respectively?
333333
18
666
36
What is the output of the following snippet?
x*y*z
x y z
1*1*1
1 1 1
What is the output of the following snippet?
[1, 2, 2, 2]
[1, 1, 1, 2]
[1, 2, 1, 2]
[2, 1, 1, 2]
What is the output of the following code if the user enters 0?
Very very bad input...
0.0
Very bad input...
Booo!
Bad input...
What is the result of the following division?
cannot be predicted
is equal to 0.5
is equal to 0.0
is equal to 0
The meaning of a positional argument is determined by ____
the argument's name specified along with its value
its value
its connection with existing variables
its position within the arguments list
Which of the following sentences are true about the code?
(Select ALL that apply)
vals and nums are different names of the same list
vals is longer than nums
nums and vals are different lists
nums has the same length as vals
An operator able to check whether two values are not equal is coded as ____
!=
not ==
<>
=/=
What is the output of the following snippet?
0 0
1 1
1 0
0 1
What is the output of the following piece of code if the user enters 2 and 4 respectively?
2.0
4.0
0.0
1.0
What brackets are used to create a list?
()
[]
{}
<>
What will this code do?
Print Numbers 1-11
Print Numbers 1-10
Print Numbers 2-10
Print Error
What is the output of the following piece of code?
2 1 2
1 2 1
1 1 2
1 2 2
The ** operator ______
performs duplicated multiplication
performs floating point multiplication
performs exponentiation
does not exist
What is the output of the following snippet if the user enters two lines containing 3 and 6 respectively?
333333
18
666
36
What is the output of the following snippet?
25.
17.0
17
the code will cause a runtime error
How many hashes (#) will the following snippet sent to the console?
three
nine
zero
six
What is the output of the following snippet?
4
the snippet is erroneous and will cause SyntaxError
2
6
The following snippet ____
will output None
is erroneous
will output 4
will output 2
Take a look at the snippet and choose the true statement or statements
the snippet will cause a runtime error
vals is longer than nums
nums is longer than vals
nums and vals have the same length
both are empty lists
What is the output of the following snippet?
one
two
three
('one', 'two', 'three')
What is the output of the following snippet?
1
2
0
the snippet will cause a runtime error
What is the output of the following snippet?
12
(2,1)
(1,2)
21
What is the output of the following snippet?
[0, 1, 9, 16]
[1, 4, 9, 16]
[0, 1, 4, 9]
[0, 1, 4, 16]
What will happen when you attempt to run the following code?
The code will print Hello, World! to the console
The code will raise the SyntaxError exception
The code will raise the TypeError exception
The code will raise the ValueError exception
What is the output of this code?
112
122
201
121
What is the output of the following piece of code if the user enters 3 and 6 respectively?
6
36
63
3
What is the output of the following snippet?
1
2
0
the snippet will cause a runtime error
