Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

PCEP FINAL EXAM

Total questions: 60

Worksheet time: 39mins

Name
Class
Date
1.

What will the output be after executing the following code snippet?

a)

3

b)

9

c)

1

d)

18

2.

What will the output be, if we run the following code?

a)

Monday, Tuesday, Wednesday, Thursday

b)

Friday

c)

None

d)

AttributeError: 'tuple' object has no attribute 'append'

3.

How many times will it print "#"?

a)

1

b)

2

c)

3

d)

4

4.

What is the output of this code when "robert" is entered by the user when prompted?

a)

True

b)

error

c)

Robert

d)

False

5.

What would be printed to the console after the following code is executed?

a)

Hello

b)

"Hello", World

c)

Hello World

d)

Hello, World

6.

What will the output be after executing the following code?

a)

('Python', 'Tuple')

b)

[Python, Tuple]

c)

['Python', 'Tuple']

d)

(Python, Tuple)

7.

What is the output when the following code snippet is run:

a)

Error

b)

None

c)

Let's enjoy a bowl of cereals

d)

Groceries trip pending

8.

What will the output be after executing the following code?

a)

[6]

b)

[0, 1, 2, 3, 4, 5]

c)

-6

d)

(0,1,2,3,4)

9.

What will the output be after executing the following code?

a)

dict{'Python', 'Dictionaries'}

b)

dict({'Python', 'Dictionaries'})

c)

{'Python', 'Dictionaries'}

d)

{1: 'Python', 2: 'Dictionaries'}

10.

What is the output of this code after the user inputs "Python" when prompted?

a)

PythonPythonPython

b)

error

c)

Python*3

d)

Python Python Python

11.

What will the output be after running the following code?

a)

[0,1,2,3,4,5]

b)

(0,1,2,3,4,5,6)

c)

[0, 1, 2, 3, 4, 6]

d)

[1,2,3,4,5,6]

12.

What will the output be, if we execute the following code?

a)

{'Name': 'Python', [1, 2, 3, 4], 'hi'}

b)

{'Name': 'Python', 1: [1, 2, 3, 4], 2: 'hi'}

c)

Syntax Error

d)

{'Python', [1, 2, 3, 4], 'hi'}

13.

What will the output be, if we run the following code?

a)

0 1

1 1

0 0

1 0

b)

0 1

0 0

1 1

1 0

c)

0 1

0 0

1 0

1 1

d)

0 1

1 1

1 0

0 0

14.

What will the output be after executing the following code?

a)

Hello "\nPython!"

b)

Hello Python!

c)

Hello

Python!

d)

Hello \nPython!

15.

What will the output be after running the following code snippet?

a)

Robert method karamagi

b)

Robert method Karamagi

c)

Robert Method Karamagi

d)

ROBERT METHOD KARAMAGI

16.

What will the output be after calling the following function?

a)

6

b)

Syntax Error

c)

6 5

d)

5

17.

What will the output be after running the following code snippet?

a)

19

b)

Syntax Error

c)

True

d)

False

18.

What would be printed to the console after the following code is

executed?

a)

2,4,6,8,10,

b)

2,4,6,8,

c)

1,3,5,7,9,

d)

1,3,7,9,

19.

What will the output be after executing the following code snippet?

a)

Nothing is printed

b)

3

c)

-1

d)

P

20.

What will the output be, if we run the following code?

a)

No Output

b)

{1: One, 2: Two}

c)

{1:"One", 2:"One"}

d)

{1: "One",1 : "One"}

21.

What will the output be after running the following code?

a)

[1, 2, 3, 4, 5, 6]

b)

[7, 6, 5, 4, 3, 2, 1]

c)

[0, 1, 2, 3, 4, 5, 6]

d)

[7, 1, 2, 3, 4, 5, 6]

22.

What is the output of this code when 'wi' and 'fi' are entered by the user

when prompted and stored in a and b, respectively?

a)

wifiwiwifi

b)

wifiwifiwifi

c)

wifififi

d)

wififififi

23.

What will the output be after executing the following code?

a)

Hello#World#Python

b)

error

c)

#Hello#World#Python

d)

HelloWorldPython#

24.

What is the output of the following code?

a)

error

b)

4

c)

2

d)

1

25.

What is the output of the following code?

a)

error

b)

<class 'int'>

c)

<class 'tuple'>

d)

Invalid Data Type

26.

What will the output be after running the following code?

a)

odd

b)

even

27.

What will the output be after running the following code?

a)

error

b)

5 10

c)

10 5

d)

Prints nothing

28.

What will the output be after running the following code?

a)

Prints nothing

b)

1 5

c)

error

d)

5 1

29.

Will the following code run without errors?

a)

This code will run without errors.

b)

This code will not run.

30.

What is the output after executing the following code?

a)

Oranges Mangoes

b)

Apple Mangoes

c)

Apple Oranges

d)

Apple Oranges Mangoes

31.

A binary code consists of:

a)

a sequence of bits which encodes machine instructions

b)

a list of keywords

c)

a set of a certain alphabet symbols

d)

a sequence of ASCII characters

32.

To run the code given as a source file whose name has the .py extension you need to have:

a)

an MS windows computer

b)

a Python editor

c)

a Python compiler

d)

a Python interpreter

33.

velocity = ​ ​ (a)   ​ ​ (b)   ​ (c)   ​ (d)   ​ (e)  

Choose from the below words
float
(
input
("Enter speed in knots: " )
)
print
int
string
;
34.

Match the following data types:

a)

-1_999

1.

Integer

b)

" 100 "

2.

String

c)

False

3.

Boolean

d)

3.14127

4.

Float

35.

Arrange the following arithmetic operators in order which reflects their priorities , where the first one has the highest priority and last has the lowest priority.

a)

Parentheses

b)

Exponents

c)

Division

d)

Subtraction

1)
2)
3)
4)
36.

​ ​ (a)   ​ (b)   ​ (c)   ​ (d)   ​ (e)  

Choose from the below words
if
tax_rate
<
23.5
:
>
==
25.3
elif
else
37.

Drag and drop the conditional expressions to obtain a code which outputs ### to the screen.

shift = 5 - 4 * 2

if shift > 0:

print("#")

elif ​ (a)   :

print("##")

elif​ (b)   :

print("###")

Choose from the below words
shift == 0
shift < 0
shift !=!
shift > 0
38.

​ (a)   ​ (b)   ​ ​ (c)   ​ ​ (d)   ​ (e)   ​

Choose from the below words
for
number in
range(
-3,
0, 1):
while
>
3
1
0
39.

Which expression evaluates to True? (select two answers)

a)

numbers[-10]

b)

numbers[numbers[0]]

c)

numbers[numbers[1]]

d)

numbers[0:4]

40.

Which expression evaluates to False? (select two answers)

a)

the_data.index(the_data[-1])== 0

b)

len(the_data[0:2]) == 0

c)

-2 in the_data[2:4]

d)

the_data.index(-2) no in the_data

41.
a)

233

b)

FTS

c)

The code has an error

d)

FlyingScotsmanTGVShinkansen

42.

What will be the output of this program if the user enters "Han" and then "Solo"?

a)

An error

b)

Nothing

c)

first surname

d)

Han Solo

43.
Which of the following best describes the order in which these lines are processed in Python?
a)
4, 1, 2
b)
4, 2, 1
c)
1, 2, 3, 4
d)
3, 1, 2
44.

Division by zero is an example of what type of error?

a)

Syntax Error

b)

Run-time Error

c)

Semantic Error

45.

Improper indentation is an example of what type of error?

a)

Syntax Error

b)

Run-time Error

c)

Semantic Error

46.

What type of error is this?

a)

syntax

b)

runtime

c)

logical

d)

user

47.

A complete set of commands is known as:

a)

Instruction list

b)

Code laws

c)

Command-line

d)

Command list

48.

What is IDLE?

a)

An acronym that stands for Integrated Development and Learning Environment for python

b)

A version of Python

c)

An acronym that stands for Interactive Development and Learning Extension

d)

An acronym that stands for Individual Development Language Exclusive

49.

What do you call a tool that lets you launch your code step-by-step and inspect it at each moment of execution?

a)

A console

b)

A debugger

c)

An editor

d)

A notepad

50.

Python is an example of:

a)

a natural language

b)

a machine language

c)

a high-level programming

d)

an English language

51.

What are the main difference between tuples and list?

a)

tuples have [] and list have ()

b)

Tuples have () and list have []

c)

tuples can be change and list cannot be changed

d)

tuples cannot be changed and list can be changed

52.

Which of the following is true about Dictionaries?

a)

Consist of key-value pairs

b)

enclosed with [ ]

c)

Only consist of integers

d)

Only Consist of Strings

53.

What is the key difference between list and tuples?

a)

List only contain integers and tuples contain strings

b)

List are able to change elements and size where tuples are not.

c)

List hold more values than Tuples

d)

List can only contain strings and Tuples can only contain integers

54.

Which is the correct way to declare 3 variables, 'a' , 'b', 'c' to 1?

a)

a = b = c = 1

b)

a,b,c = 1

c)

a == b

b == c

c == 1

d)

abc = 1

55.

Evaluate the following expression in Python?

24 // 4 // 4

a)

1

b)

2

c)

24

d)

1.5

56.

Evaluate the following arithmetic expression in Python ?

2 ** 2 ** 3

a)

256

b)

48

c)

64

d)

512

57.

56.867

a)

String

b)

Integer

c)

Float

d)

Decimal

58.

"89 / 90"

a)

String

b)

Integer

c)

Float

d)

Number

59.

Which of the following best describes the concept of "scope" in Python?

a)

The process of converting source code into machine code.

b)

The area of a program where a variable is defined and can be accessed.

c)

A collection of related data and methods that act on that data.

d)

The process of finding and fixing errors in a program.

60.

How is a try and catch used in python?

a)

It is like an if then else which shows our error if there is one and it does not

b)

It is used to check if a snippet of code has an error and if it does it allows us to handle the error without terminating the program

c)

it tries a snippet of code then it catches the value that it sends, similar as a return

d)

It returns an error and terminates the program so we may identify what was the issue