Font size
WorksheetsPython Baseline Test (PCAP I)
Total questions: 60
Worksheet time: 51mins
What is true about compilation?
It tends to be faster than interpretation
(b) It tends to be slower than interpretation
The code is converted directly to machine code executable by the processor
(d) both you and the end user must have the compiler to run your code
Which of the following variable names are illegal?
(Select ALL that apply)
TRUE
True
and
true
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
Left-sided binding determines that the result of the expression above is equal to:
0.0
0.16666666666666
0
4.5
What is the output of the following snippet if the user enters two lines containing 2 and 4 respectively?
8.0
2.0
4.0
the code will cause a runtime error
The \n digraph forces the print() function to ______
Output exactly two characters: \ and n
duplicate the character next to the digraph
stop its execution
break the output line
What is the output of the following snippet if the user enters two lines containing 2 and 4 respectively?
8.0
2.0
4.0
the code will cause a runtime error
What is the output of the following snippet?
x*y*z
x y z
1*1*1
1 1 1
What is the result of the following division?
is equal to 1
is equal to 1.0
cannot be evaluated
cannot be predicted
What is the output of the following snippet?
2 2
2 1
1 1
1 2
What is the output of the following snippet?
25.
17.0
17
the code will cause a runtime error
How many stars (*) will the following snippet send to the console?
two
one
the snippet will enter an infinite loop, printing one star per line
zero
What is the output of the following piece of code?
2 1 2
1 2 1
1 1 2
1 2 2
How many hashes (#) will the following snippet sent to the console?
three
nine
zero
six
What is the output of the following piece of code if the user enters two lines containing 3 and 2 respectively?
2
3
0
1
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
What is the output of the following piece of code?
0
0.2
0.4
0.0
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
What is the output of the following piece of code if the user enters 3 and 6 respectively?
6
36
63
3
Take a look at the snippet and choose the true statement
the snippet will cause a runtime error
vals is longer than nums
nums is longer than vals
nums and vals have the same length
Which of the following lines correctly invokes the function defined below?
(Select ALL that apply)
fun(b=1)
fun(0, 1, 2)
fun()
fun(b=0, a=0)
Assuming that my_tuple is a correctly created tuple, the fact that tuples are immutable means that the instruction is ____
can only be executed if and only if the tuple contains at least two elements
is illegal
is fully correct
may be illegal if the tuple contains strings
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 piece of code?
abc
asepbsepc
a b c
asepbsepcsep
What is the output of the following snippet?
44
(4,)
4
(4)
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 following snippet:
will output 16
will cause a runtime error
will output 2
will output 4
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
What is the output of the following snippet?
0 0
1 1
1 0
0 1
An operator able to check whether two values are not equal is coded as ____
!=
not ==
<>
=/=
What is the output of the following snippet?
the code is erroneous (the dict object has no vals() method)
0 0
1 0
0 1
What is the output of the following snippet?
[0, 1, 9, 16]
[1, 4, 9, 16]
[0, 1, 4, 9]
[0, 1, 4, 16]
print()
input()
output()
command()
Which statement correctly assigns the string "Sarah" to the variable name?
name = print( "Sarah")
input("Sarah")
name = "Sarah"
name = input("Sarah")
What would this print?
What is the Python built-in function to converts a number to a string?
str()
int()
parseInt()
convert
Which of these is correct Python conditional statement?
IF answer == "Yes":
if answer == "Yes"
if answer == "Yes":
if answer = "yes":
What is a String?
A data type that contains whole numbers. eg: 3, 45, 124
Numbers with decimal point. eg: 0.5, 2.45, 56.04
Group of characters between quotation marks. eg: "dog"
Data type that can only be True or False.
Which value is a Float?
64
"cat"
True
0.5
What will this code do?
Print Numbers 1-11
Print Numbers 1-10
Print Numbers 2-10
Print Error
What brackets are used to create a list?
()
[]
{}
<>
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 is the output of the following snippet?
the code will cause a runtime error
2
2None
1
How many elements does the lst list contain?
zero
three
one
two
What value will be assigned to the x variable?
0
True
False
1
Which of the following variable names are illegal and will cause a SyntaxError?
(Select ALL that apply)
in
In
for
Which one of the statements below will cause an error?
ans = “hi” * 8
ans = “hi” + 9
ans = “hi” + “hi” + “hi”
ans = (“a” * 4) + “b”
Suppose you have a variable defined a = "4". What is the variable type of a?
str
int
float
number
What is the final result of the expression 2**3?
6
8
2
That is not a valid Python expression.
What extension must you add to the end of a file when saving?
.c
.java
.py
.pyc
