WorksheetsPCEP FINAL EXAM
Total questions: 60
Worksheet time: 39mins
What will the output be after executing the following code snippet?
3
9
1
18
What will the output be, if we run the following code?
Monday, Tuesday, Wednesday, Thursday
Friday
None
AttributeError: 'tuple' object has no attribute 'append'
How many times will it print "#"?
1
2
3
4
What is the output of this code when "robert" is entered by the user when prompted?
True
error
Robert
False
What would be printed to the console after the following code is executed?
Hello
"Hello", World
Hello World
Hello, World
What will the output be after executing the following code?
('Python', 'Tuple')
[Python, Tuple]
['Python', 'Tuple']
(Python, Tuple)
What is the output when the following code snippet is run:
Error
None
Let's enjoy a bowl of cereals
Groceries trip pending
What will the output be after executing the following code?
[6]
[0, 1, 2, 3, 4, 5]
-6
(0,1,2,3,4)
What will the output be after executing the following code?
dict{'Python', 'Dictionaries'}
dict({'Python', 'Dictionaries'})
{'Python', 'Dictionaries'}
{1: 'Python', 2: 'Dictionaries'}
What is the output of this code after the user inputs "Python" when prompted?
PythonPythonPython
error
Python*3
Python Python Python
What will the output be after running the following code?
[0,1,2,3,4,5]
(0,1,2,3,4,5,6)
[0, 1, 2, 3, 4, 6]
[1,2,3,4,5,6]
What will the output be, if we execute the following code?
{'Name': 'Python', [1, 2, 3, 4], 'hi'}
{'Name': 'Python', 1: [1, 2, 3, 4], 2: 'hi'}
Syntax Error
{'Python', [1, 2, 3, 4], 'hi'}
What will the output be, if we run the following code?
0 1
1 1
0 0
1 0
0 1
0 0
1 1
1 0
0 1
0 0
1 0
1 1
0 1
1 1
1 0
0 0
What will the output be after executing the following code?
Hello "\nPython!"
Hello Python!
Hello
Python!
Hello \nPython!
What will the output be after running the following code snippet?
Robert method karamagi
Robert method Karamagi
Robert Method Karamagi
ROBERT METHOD KARAMAGI
What will the output be after calling the following function?
6
Syntax Error
6 5
5
What will the output be after running the following code snippet?
19
Syntax Error
True
False
What would be printed to the console after the following code is
executed?
2,4,6,8,10,
2,4,6,8,
1,3,5,7,9,
1,3,7,9,
What will the output be after executing the following code snippet?
Nothing is printed
3
-1
P
What will the output be, if we run the following code?
No Output
{1: One, 2: Two}
{1:"One", 2:"One"}
{1: "One",1 : "One"}
What will the output be after running the following code?
[1, 2, 3, 4, 5, 6]
[7, 6, 5, 4, 3, 2, 1]
[0, 1, 2, 3, 4, 5, 6]
[7, 1, 2, 3, 4, 5, 6]
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?
wifiwiwifi
wifiwifiwifi
wifififi
wififififi
What will the output be after executing the following code?
Hello#World#Python
error
#Hello#World#Python
HelloWorldPython#
What is the output of the following code?
error
4
2
1
What is the output of the following code?
error
<class 'int'>
<class 'tuple'>
Invalid Data Type
What will the output be after running the following code?
odd
even
What will the output be after running the following code?
error
5 10
10 5
Prints nothing
What will the output be after running the following code?
Prints nothing
1 5
error
5 1
Will the following code run without errors?
This code will run without errors.
This code will not run.
What is the output after executing the following code?
Oranges Mangoes
Apple Mangoes
Apple Oranges
Apple Oranges Mangoes
A binary code consists of:
a sequence of bits which encodes machine instructions
a list of keywords
a set of a certain alphabet symbols
a sequence of ASCII characters
To run the code given as a source file whose name has the .py extension you need to have:
an MS windows computer
a Python editor
a Python compiler
a Python interpreter
velocity = (a) (b) (c) (d) (e)
Match the following data types:
-1_999
Integer
" 100 "
String
False
Boolean
3.14127
Float
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.
Parentheses
Exponents
Division
Subtraction
(a) (b) (c) (d) (e)
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("###")
(a) (b) (c) (d) (e)
Which expression evaluates to True? (select two answers)
numbers[-10]
numbers[numbers[0]]
numbers[numbers[1]]
numbers[0:4]
Which expression evaluates to False? (select two answers)
the_data.index(the_data[-1])== 0
len(the_data[0:2]) == 0
-2 in the_data[2:4]
the_data.index(-2) no in the_data
233
FTS
The code has an error
FlyingScotsmanTGVShinkansen
What will be the output of this program if the user enters "Han" and then "Solo"?
An error
Nothing
first surname
Han Solo
Division by zero is an example of what type of error?
Syntax Error
Run-time Error
Semantic Error
Improper indentation is an example of what type of error?
Syntax Error
Run-time Error
Semantic Error
What type of error is this?
syntax
runtime
logical
user
A complete set of commands is known as:
Instruction list
Code laws
Command-line
Command list
What is IDLE?
An acronym that stands for Integrated Development and Learning Environment for python
A version of Python
An acronym that stands for Interactive Development and Learning Extension
An acronym that stands for Individual Development Language Exclusive
What do you call a tool that lets you launch your code step-by-step and inspect it at each moment of execution?
A console
A debugger
An editor
A notepad
Python is an example of:
a natural language
a machine language
a high-level programming
an English language
What are the main difference between tuples and list?
tuples have [] and list have ()
Tuples have () and list have []
tuples can be change and list cannot be changed
tuples cannot be changed and list can be changed
Which of the following is true about Dictionaries?
Consist of key-value pairs
enclosed with [ ]
Only consist of integers
Only Consist of Strings
What is the key difference between list and tuples?
List only contain integers and tuples contain strings
List are able to change elements and size where tuples are not.
List hold more values than Tuples
List can only contain strings and Tuples can only contain integers
Which is the correct way to declare 3 variables, 'a' , 'b', 'c' to 1?
a = b = c = 1
a,b,c = 1
a == b
b == c
c == 1
abc = 1
Evaluate the following expression in Python?
24 // 4 // 4
1
2
24
1.5
Evaluate the following arithmetic expression in Python ?
2 ** 2 ** 3
256
48
64
512
56.867
String
Integer
Float
Decimal
"89 / 90"
String
Integer
Float
Number
Which of the following best describes the concept of "scope" in Python?
The process of converting source code into machine code.
The area of a program where a variable is defined and can be accessed.
A collection of related data and methods that act on that data.
The process of finding and fixing errors in a program.
How is a try and catch used in python?
It is like an if then else which shows our error if there is one and it does not
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
it tries a snippet of code then it catches the value that it sends, similar as a return
It returns an error and terminates the program so we may identify what was the issue
