Font size
WorksheetsPython PCEP
Total questions: 150
Worksheet time: 2hrs 45mins
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
What do you expect the following code will print given the first input is
apple (stored in variable a) and the second input is banana (stored in
variable b)?
apple:banana
apple::banana
banana:apple:
banana::apple
What will the output be after running the following code snippet?
0
4
2
1
What will the output be after running the following code snippet?
['bananas', '']
['bananas']
['apples']
['apples', 'bananas', '']
What will the output be after running the following code snippet?
[7, 6, 5, 4, 3, 2, 1]
[1, 2, 3, 4, 5, 6, 7]
[1, 2, 3, 4, 5, 6]
[2, 3, 4, 5, 6, 7]
What will the output be after running the following code snippet?
0b01
0b11
0b10
10
What is the output of the following program?
1
9
10
90
What will the output be after running the following code snippet?
Not equal
Equal
False
True
What will the output be after running the following code snippet?
4
error
1
9
What is the output of the following snippet of code:
2
3
Nothing is printed
0
What will the output be after running the following code snippet?
Values are the same
Values are different
True
False
What do you expect the following code to print:
[5, 4, 3, 2, 1]
[1, 2, 3, 4, 5]
[1, 2, 3, 4]
[5, 1, 2, 3, 4]
What will the output be after running the following code snippet?
100
20
error
x not defined
What will the output be after running the following code snippet?
[1, 1, 2, 2, 3, 3]
[1, 2, 3, 1, 2, 3]
[1, 2, 3, 3, 2, 1]
[1, 2, 3]
What will the output be after executing the following code snippet?
error
Yes
No
0
What will the output be after running the following code snippet?
hello prof karamagi
HelloProfKaramagi
Hello prof karamagi
Hello Prof Karamagi
What will the output be after running the following code snippet?
(1, 2, 3), ('apples', 'banana', pears')
(1, 2, 3) + ('apple', 'banana'. 'pears')
(1, 2, 3, 'apples', 'banana', 'pears')
('apple, 'banana', 'pears', 1, 2, 3)
What will happen if the following snippet of code is executed?
Hello ""
Hello "name"
Hello, name
Hello
What will the output be after running the following code snippet?
Robert,Karamagi
Robert ","Karamagi
Robert Karamagi
RobertKaramagi
What will the output be after running the following code snippet?
No Class
First Class
Second Class
Third Class
What will the output be after running the following code snippet?
64
12
7
6
What will the output be after running the following code snippet?
--
"
Nothing; no newline/blank
'--'
What will the output be after running the following code snippet?
[[10, 2, 3]]
[[1, 2, 3]]
[[10, 1, 2, 3]]
[[10]]
What will the output be after running the following code snippet?
not valid
greater than 10
less than 10
syntax error
What will the output be after running the following code snippet?
{'one': 0, 'two': 1}
{'one': 0, 'two': 2}
{'one': 1, 'two': 2}
{'one': 1, 'two': 0}
What will the output be after running the following code snippet?
Python,Python
Python','Python
PythonPython
Python,*2
What will the output be after running the following code snippet?
error
('Peter', 'Piper', 'Pickled', 'Pepper')
('Peter')
['Peter', 'Piper', 'Pickled', 'Pepper']
What do you expect to be output to the console?
False
True
Python is Awesome!
Hello, World!
What will the output be after running the following code snippet?
error
2
2.0
5
What do you expect the following code snippet to printout:
('P', 'y', 't', 'h', 'o', 'n')
('W', 'o', 'r', 'l', 'd', '!')
('n', 'o', 'h', 't', 'y', 'P')
[P, y, t, h, o, n]
What will the output be after running the following code snippet?
6
4
9
error
What will be the output after running the following code?
func1
func3
func3
func3
func3
func1
func1
func2
func3
func3
func2
func1
What will be the output after running the following code?
[7, 2]
[7, 6, 5, 4, 3, 2]
[7, 3]
SyntaxError
What will be the output after running the following code?
Yes
True
error
No
What will be the output when the following program is run?
5,4,'Earth'
[5,4]
[5, 4, 'Earth']
{5,4,'Earth'}
What is the output of the following code:
<class 'tuple'>
<class 'list'><class 'int'>
<class 'list'>
error
What will the output be after executing this code?
True True False
False False True
False True False
False False False
What is the output of the following print statement ?
False
True
SyntaxError
10
What is the output when the following code is executed:
['o', 'u']
['a', 'e', 'i']
['a', 'e', 'i', 'o', 'u', 'a', 'e', 'i', 'o', 'u']
['a', 'e', 'i', 'o', 'u']
What will be the output after running the following code?
AttributeError
['Tuple']
[]
['Python']
What do we need to change in order to fix the following code:
error as the variable name str is invalid
None of the above
Wrap the whole sentence in a single quotes and leave Piper and Pepper in double quotes as is
Escape the quotes around Piper and Pepper words using the \ character.
What would the following program print to the console when user inputs 3 and 'Python' to be stored in the a and b variables respectively?
"Python Python Python"
Python
PythonPythonPython
SyntaxError
What do you expect the following code to produce?
G
Good Night
Good Morning
Go
What will be the output after running the following code?
(1, 2, 3, 'Apples', 'Bananas')
SyntaxError
(1, 2, 3)('Apples', 'Bananas')
('Apples', 'Bananas', 1, 2, 3)
Given x and y are two binary numbers, what would the AND (&) operator on these number yield?
0b110
0b101
0b001
0b100
What do you expect the following print statement to produce ?
False
Butter
"Butter"
True
What will be the output after running the following code?
False
Error
hi
bye
What will the output be after executing this code?
error
The program will infinitely print {'blue' : 1,'red' : 2,'yellow': 3} .
{'blue' : 1,'red' : 2,'yellow': 3}
Nothing is printed
What do you expect the following code to print out:
1
2
5
error
What will be the output when the following program is run?
Hello World Python
Hello World
HelloWorld Python
HelloWorldPython
What will be the output after running the following code?
1 : 1
1 : 2
2 : 2
2 : 1
What will be the output after running the following code?
9
9+y
0
error
What will the output be after executing the following code?
apples
bananas
error
1 apples
1 bananas
1 apples
2 bananas
What is the output of the following print statement:
Knowledge Is Power
KnowledgeIsPower
error
"Knowledge Is Power"
What will be the output after running the following code?
error
Java
Python
1
What will the output be when the following code is executed?
Invalid input
5
6
7
What will be the output after running the following code?
1
[('first', 3),('third', 2)]
[('first', 3),(1),('third', 2)]
second
What will the output be after running the following code snippet?
0,1,2,3,4,5
6
1,2,3,4,5,6
5
What is the output of the following code:
[1, 2, 3][1, 2, 3]
error
[4, 5, 6, 7] [1, 2, 3]
[1, 2, 3][4, 5, 6, 7]
What is the output of the following code:
40
100
20
200
What is the output of the following code:
10
error
9
5
What will be the output after running the following code?
45
10
1
55
What will be the output after running the following code?
['bananas', 'apples', 'strawberries', 'peas']
['bananas', 'apples', 'pears', 'strawberries']
['bananas', 'apples', 'strawberries']
['strawberries', 'strawberries', 'strawberries']
What will be the output after running the following code?
8
27
216
error
What will be the output after running the following code?
1 1
error
0 0
0 1
What does the following code do?
2.0
0.5
0
2
What will be the output after running the following code?
3.0
3
TypeError
21.0
What will be the output after running the following code?
8hi
2hi
hi
4hi
Mark the correct sentence about the break statement in a for loop?
Break statement does not affect flow of the loop
Break will terminate the current iteration but will resume with the next iteration
Break will terminate the entire loop
Break statement in an inner loop will terminate the both inner and outer loop
What will be the output after running the following code?
Value of i : i
Value of i : 6
6
SyntaxError
What will be the output after running the following code?
0b1110
0b1111
0b1101
0b1100
What will be the output after running the following code?
["Tuesday", "Monday", "Wednesday", "Thursday", "Friday"]
[ "Monday", "Tuesday, "Wednesday", "Thursday", "Friday"]
["Monday", "Wednesday", "Thursday"]
["Tuesday","Friday", "Monday", "Wednesday", "Thursday"]
What is the output of the code below:
60
90
90
60
90
60
What will be the output after running the following code?
Earth
Earth Jupiter
2
2 True
What will be the output after the following code is executed?
Hello World
HelloWorld
HelloNoneWorld
Hello,World
What will be the output after running the following code?
((-1, 0, 1), 'bananas')
(-1, 0, 1, 'bananas')
(-1, 0, 1)('bananas')
('bananas', (-1, 0, 1))
What will be the output after running the following code?
2
0.4
SyntaxError
2.5
What will be the output after running the following code?
Fixed
Temp
error
True
What is the output of this code when 'Robert' and 13 are entered by the user and stored in variables name and age, respectively?
Robert <class 'int'>
Robert 13(int)
Robert 13
SyntaxError
What will be the output after running the following code?
0 1 2
1 2 3
0 1 2 2
0 1 2 3
What will be the output after the following code is executed?
not True
False
not False
True
What will be the output after running the following code?
['Python', 'weekends', ['Saturday', Sunday']]
{'Python', ["Saturday", "Sunday"]}
IndexError
{0: 'Python', 'weekends': ['Saturday', 'Sunday']}
What will be the output of the following code?
A blank space
error
A blank line
Nothing is printed
What is the output when the following program is executed?
[3.14, True]
['apples', 3.14, True]
[1, "apples", 3.14, True]
[1, 2, "apples"]
What do you expect the following code to produce:
error
Good Morning
Good Night
Good name=""
What will be the output after running the following code?
36
30
error
invalid input
Is this the correct way to write the code?
No, the syntax is incorrect
Yes, the syntax is correct
What will be the output after running the following code?
False
True
error
hello
What will be the output after running the following code?
[1, 2, 3, 2, 1]
[1, 1, 2, 2, 3]
[1, 2, 3, 1, 2]
error
What will be the output after running the following code?
not equal
False
True
equal
What will be the output after running the following code?
('Python', 'World', 'Python', 'World')
error
('Python', 'World')('Python', 'World',)
('Python', 'World', 2)
Which of the following statements is incorrect:
An indentation in Python language is mandatory
The '#' is used as single line comments and the """ """ (triple quote) is used as multi-line comments
We don't need to declare the type of a variable in Python program
All of these are correct.
What will the output be when the following code is executed?
"Robert, 123455667, Dar es salaam "
Robert 123455667 Dar es salaam
SyntaxError
Robert' 123455667 'Dar es salaam '
What will be the output when the following code is executed?
\n:\n:\n
:
:
:
Three blank lines
error
What will be the output when the following code is executed?
25
256
error
25.6
Which of the following statements is incorrect (select all that apply):
The bool("123") will return True
The bool("") will return True
The bool({}) will return False
The bool(-1) will return False
What would be the output of the following code:
1
2
4
25
What will be the output when the following code is executed?
False
True
SyntaxError
error
What will be the output when the follownig code is executed?
0b00111
0b11111
0b11110
0b11100
What will be the output of the following print statements?
False
True
True
True
False
False
True
False
What will be the output when the follownig code is executed?
error
Type Error: object of type 'int' has no len()
4
0
What will be the output of the following print statement?
Hello P
str is a keyword so the assignment isn't valid
Python!
Hello Python!
What is the output of the following code snippet:
Oranges
'Apple', 'Oranges', 'Bananas'
Bananas
error
What will be the output of the following print statement?
3
error
1.,2.3.
'Earth
Which of the following statements is correct?
A tuple cannot be modified once created, as they are immutable by design
Adding tuples will produce a new tuple
The elements in a tuple can be accessed by using their index position
All of these are correct.
What is the result of the following print statement?
['Milk', 'Cheese']
['Bread', 'Butter']
['Milk', 'Cheese', 'Bread', 'Butter']
SyntaxError
What is the result of the following print statement?
"New York"
['London', 'Rome']
["London","New York","Rome"]
SyntaxError
What would be the output of the following code when executed?
{1: 'iOS', 2: 'Android'}
{1: 'iOS', 'Android'}
{'iOS', 'Android'}
{1: 'iOS'}
What will be the output of the following code when executed?
London
Paris
Berlin
UK
France
Germany
('London', 'UK') ('Paris', 'France') ('Berlin', 'Germany')
('UK', 'London') ('France', 'Paris') ('Germany', 'Berlin')
What will be the output of the following code when executed?
hi
SyntaxError
bye
error
Is this the correct way to write the code?
Yes, the syntax is correct.
No, the syntax is incorrect.
What will be the output of the following code when executed?
1
2
3
1
2
3
hi
1
2
1
2
hi
What will be the output of the following code when executed?
1
2
3
hi
1
2
3
1
error
What will be the output of the following code when executed?
Break
1
2
3
4
SyntaxError
1
What will be the output of the following code when executed?
1
2
3
Break
1
2
3
4
Break
Break
1
2
3
4
What is the result of the following code when executed?
20
19
16
What will be the output of the following code when executed?
['a', 'b', 'c', 'c']
['a', 'b', 'c', 'd']
['a', 'c', 'c', 'd']
SyntaxError
What will be the output of the following code when executed?
Cappuccino', 'Latte', 'Macchiato'
['Tea']
Cappuccino', 'Latte', 'Macchiato', 'tea'
error
What will be the output of the following code when executed?
10
error
24
1
What will be the output of the following code when executed?
Dar es salaam
A', 'A*', 'A+'
Robert
Robert', 'Dar es salaam', ['A', 'A*', 'A+']
What is the output of the following code?
Robert: 29: Dar es salaam
NAME='Robert, AGE=29, CITY='Dar es salaam'
NAME:Robert AGE:29 CITY:Dar es salaam
SyntaxError
