wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Baseline Test (PCAP I)

Total questions: 60

Worksheet time: 51mins

Name
Class
Date
1.

What is true about compilation?

a)

It tends to be faster than interpretation

b)

(b) It tends to be slower than interpretation

c)

The code is converted directly to machine code executable by the processor

d)

(d) both you and the end user must have the compiler to run your code

2.

Which of the following variable names are illegal?

(Select ALL that apply)

a)

TRUE

b)

True

c)

and

d)

true

3.

The ** operator ______

a)

performs duplicated multiplication

b)

performs floating point multiplication

c)

performs exponentiation

d)

does not exist

4.

What is the output of the following snippet if the user enters two lines containing 3 and 6 respectively?

a)

333333

b)

18

c)

666

d)

36

5.

Left-sided binding determines that the result of the expression above is equal to:

a)

0.0

b)

0.16666666666666

c)

0

d)

4.5

6.

What is the output of the following snippet if the user enters two lines containing 2 and 4 respectively?

a)

8.0

b)

2.0

c)

4.0

d)

the code will cause a runtime error

7.

The \n digraph forces the print() function to ______

a)

Output exactly two characters: \ and n    

b)

duplicate the character next to the digraph

c)

stop its execution

d)

break the output line

8.

What is the output of the following snippet if the user enters two lines containing 2 and 4 respectively?

a)

8.0

b)

2.0

c)

4.0

d)

the code will cause a runtime error

9.

What is the output of the following snippet?

a)

x*y*z

b)

x y z

c)

1*1*1

d)

1 1 1

10.

 What is the result of the following division?

a)

is equal to 1

b)

is equal to 1.0

c)

cannot be evaluated

d)

cannot be predicted

11.

What is the output of the following snippet?

a)

2 2

b)

2 1

c)

1 1

d)

1 2

12.

What is the output of the following snippet?

a)

25.

b)

17.0

c)

17

d)

the code will cause a runtime error

13.

How many stars (*) will the following snippet send to the console?

a)

two

b)

one

c)

the snippet will enter an infinite loop, printing one star per line

d)

zero

14.

What is the output of the following piece of code?

a)

2 1 2

b)

1 2 1

c)

1 1 2

d)

1 2 2

15.

How many hashes (#) will the following snippet sent to the console?

a)

three

b)

nine

c)

zero

d)

six

16.

What is the output of the following piece of code if the user enters two lines containing 3 and 2 respectively?

a)

2

b)

3

c)

0

d)

1

17.

The meaning of a positional argument is determined by ____

a)

the argument's name specified along with its value

b)

its value

c)

its connection with existing variables

d)

its position within the arguments list

18.

What is the output of the following piece of code?

a)

0

b)

0.2

c)

0.4

d)

0.0

19.

What is the output of the following snippet?

a)

4

b)

the snippet is erroneous and will cause SyntaxError

c)

2

d)

6

20.

The following snippet ____

a)

will output None

b)

is erroneous

c)

will output 4

d)

will output 2

21.

What is the output of the following piece of code if the user enters 3 and 6 respectively?

a)

6

b)

36

c)

63

d)

3

22.

Take a look at the snippet and choose the true statement

a)

the snippet will cause a runtime error

b)

vals is longer than nums

c)

nums is longer than vals

d)

nums and vals have the same length

23.

Which of the following lines correctly invokes the function defined below?

(Select ALL that apply)

a)

fun(b=1)

b)

fun(0, 1, 2)

c)

fun()

d)

fun(b=0, a=0)

24.

Assuming that my_tuple is a correctly created tuple, the fact that tuples are immutable means that the instruction is ____

a)

can only be executed if and only if the tuple contains at least two elements

b)

is illegal

c)

is fully correct

d)

may be illegal if the tuple contains strings

25.

What is the output of the following snippet?

a)

one

b)

two

c)

three

d)

('one', 'two', 'three')

26.

What is the output of the following snippet?

a)

1

b)

2

c)

0

d)

the snippet will cause a runtime error

27.

What is the output of the following snippet?

a)

12

b)

(2,1)

c)

(1,2)

d)

21

28.

What is the output of the following piece of code?

a)

abc

b)

asepbsepc

c)

a b c

d)

asepbsepcsep

29.

What is the output of the following snippet?

a)

44

b)

(4,)

c)

4

d)

(4)

30.

What is the result of the following division?

a)

cannot be predicted

b)

is equal to 0.5

c)

is equal to 0.0

d)

is equal to 0

31.

The following snippet:

a)

will output 16

b)

will cause a runtime error

c)

will output 2

d)

will output 4

32.

Which of the following sentences are true about the code?

(Select ALL that apply)

a)

vals and nums are different names of the same list

b)

vals is longer than nums

c)

nums and vals are different lists

d)

nums has the same length as vals

33.

What is the output of the following snippet?

a)

0 0

b)

1 1

c)

1 0

d)

0 1

34.

An operator able to check whether two values are not equal is coded as ____

a)

!=

b)

not ==

c)

<>

d)

=/=

35.

What is the output of the following snippet?

a)

the code is erroneous (the dict object has no vals() method)

b)

0 0

c)

1 0

d)

0 1

36.

What is the output of the following snippet?

a)

[0, 1, 9, 16]

b)

[1, 4, 9, 16]

c)

[0, 1, 4, 9]

d)

[0, 1, 4, 16]

37.
What is the word (command) used to display numbers and text on the screen?
a)

print()

b)

input()

c)

output()

d)

command()

38.
What Python command lets the user enter an answer to a question?
a)
answer()
b)
open()
c)
print()
d)
input()
39.

Which statement correctly assigns the string "Sarah" to the variable name?

a)

name  = print( "Sarah")

b)

input("Sarah")

c)

name = "Sarah"

d)

name = input("Sarah")

40.
In the following code, "city" is an example of a what?
a)
List
b)
Loop
c)
Variable
d)
Array
41.
print("12"*3)
What would this print?
a)
36
b)
121212
c)
24
d)
12*3
42.

What is the Python built-in function to converts a number to a string?

a)

str()

b)

int()

c)

parseInt()

d)

convert

43.

Which of these is correct Python conditional statement?

a)

IF answer == "Yes":

b)

if answer == "Yes"

c)

if answer == "Yes":

d)

if answer = "yes":

44.

What is a String?

a)

A data type that contains whole numbers. eg: 3, 45, 124

b)

Numbers with decimal point. eg: 0.5, 2.45, 56.04

c)

Group of characters between quotation marks. eg: "dog"

d)

Data type that can only be True or False.

45.

Which value is a Float?

a)

64

b)

"cat"

c)

True

d)

0.5

46.

What will this code do?

a)

Print Numbers 1-11

b)

Print Numbers 1-10

c)

Print Numbers 2-10

d)

Print Error

47.
Which of the following symbols is used in Python to mean "Less than or equal to"?
a)
<<
b)
=<
c)
<=
d)
!=
48.

What brackets are used to create a list?

a)

()

b)

[]

c)

{}

d)

<>

49.

What is the output of the following piece of code if the user enters 2 and 4 respectively?

a)

2.0

b)

4.0

c)

0.0

d)

1.0

50.

What is the output of the following snippet?

a)

the code will cause a runtime error

b)

2

c)

2None

d)

1

51.

How many elements does the lst list contain?

a)

zero

b)

three

c)

one

d)

two

52.

What value will be assigned to the x variable?

a)

0

b)

True

c)

False

d)

1

53.

Which of the following variable names are illegal and will cause a SyntaxError?

(Select ALL that apply)

a)

in

b)

print

c)

In

d)

for

54.

Which one of the statements below will cause an error?

a)

ans = “hi” * 8

b)

ans = “hi” + 9

c)

ans = “hi” + “hi” + “hi”

d)

ans = (“a” * 4) + “b”

55.

Suppose you have a variable defined a = "4". What is the variable type of a?

a)

str

b)

int

c)

float

d)

number

56.

What is the final result of the expression 2**3?

a)

6

b)

8

c)

2

d)

That is not a valid Python expression.

57.

What extension must you add to the end of a file when saving?

a)

.c

b)

.java

c)

.py

d)

.pyc

58.
To repeat a fixed number of times use a
a)
while loop
b)
for loop
c)
if loop
d)
indentation
59.
Python identifies blocks of code by
a)
BEGIN and END keywords
b)
{ and }
c)
aligning up the starts of lines (indentation)
d)
guessing
60.
The correct way to write a variable in Python?
a)
my_variable = 10
b)
my variable = 10
c)
my_variable is 10
d)
my_variable: 10