Font size
WorksheetsPython Certification Preparation
Total questions: 100
Worksheet time: 2hrs 39mins
What will be the output of the following code?
['Batman', 'Superman', 'Wonder Woman', 'Flash', 'Aquaman']
Cyborg
Batman
['Wonder Woman', 'Flash', 'Aquaman']
What will be the output of the following code?
Aquaman
Cyborg
Batman
Superman
What will be the output of the following code?
['Aquaman', 'Batman', 'Cyborg', 'Flash', 'Superman', 'Wonder Woman']
['Wonder Woman', 'Superman', 'Flash', 'Cyborg', 'Batman', 'Aquaman']
['Cyborg', 'Aquaman', 'Flash', 'Wonder Woman', 'Superman', 'Batman']
['Cyborg', 'Aquaman', 'Flash', 'Wonder Woman', 'Superman']
What will be the output of the following code?
True
true
False
false
Giving the code above, what would you need to type to print "Cyborg"?
print(justiceLeague[1])
print(justiceLeague[3])
print(justiceLeague[2])
print(justiceLeague[-1])
How can we fix this text so that it prints as:
Michael Jordan is the "GOAT"
text="Michael Jordan is the \"GOAT\""
text="Michael Jordan is the /"GOAT/""
text="Michael Jordan is the \\"GOAT\\""
text="Michael Jordan is the//"GOAT//""
What will be the output of the following code?
True
true
False
false
Giving the code above, what would you need to type to print "Wonder Woman"?
print(justiceLeague[6])
print(justiceLeague[3])
print(justiceLeague[2])
print(justiceLeague[-1])
What will be the output of the following code?
10
12
22
2
Which escape sequence is for a new line?
\n
/n
\\
\b
What will be the output of the following code?
10
12
22
2
Which escape sequence is for a new line?
\n
/n
\\
\b
Which escape sequence is for a tab?
\t
/t
\b
\f
What will be the output of the following code?
True
true
False
false
Which escape sequence is for a tab?
\t
/t
\b
\f
Which escape sequence is for a backspace?
\'
/n
\b
\f
Which escape sequence is for a form feed?
\n
\r
\b
\f
When using Python in a command line environment, what command will list available Python commands and show information on these commands when an individual command is entered?
help
help()
command()
dir
Which kind of error do you have when your program runs but the result are different from what you expect.
Runtime
Logic
Syntax
When using Python in a command line environment, what command will returns a list of valid attributes of the specified object? If no argument passed, it returns the list of names in the current local scope.
dict()
help()
command()
dir()
Exception disrupts the
Normal flow of the program
Flow of the python interpreter
Flow of memory on the hard disk
None of the Above
The unexpected event happened during program execution should be handled by
Exception
Experiment
Assertion
Termination
Assume a = 10 and b = 5, then the output will be
5.0
Something Went Wrong
Arithmetic Error
2.0
Choose the correct statement to close a file stream named myfile:
myfile.terminate()
myfile.end()
myfile.close()
myfile.remove()
Assume a = ten and b = 5, then the output will be
5.0
Something Went Wrong
Arithmetic Error
2.0
The suspicious code is put inside the
Try Block
Finally Block
Else Block
Except Block
An exception can be manually triggered by the command
raise
try
except
trigger
Assume a = ten and b = 5, then the output will be
5.0
Something Went Wrong
Arithmetic Error
2.0
Which function is used to write multiple lines in text file?
write()
writelines()
lines()
print()
Assume a = 10 and b = 5, then the output will be
5.0
Something Went Wrong
Arithmetic Error
2.0
The unexpected event happened during program execution should be handled by
Exception
Experiment
Assertion
Termination
Exception disrupts the
Normal flow of the program
Flow of the python interpreter
Flow of memory on the hard disk
None of the Above
The suspicious code is put inside the
Try Block
Finally Block
Else Block
Except Block
An exception can be manually triggered by the command
raise
try
except
trigger
Is the following Python code valid?
try:
# Do something
except:
# Do something
else:
# Do something
no, there is no such thing as else
no, else cannot be used with except
no, else must come before except
yes
What Python method lets the user enter an answer to a question via the keyboard?
answer()
open()
print()
input()
What will be the output to the console for the code below?
print(3%6 )
.5
12
2
3
Which of the following is not an exception handling keyword in Python?
accept
finally
try
except
Which function is used to write multiple lines in text file?
write()
writelines()
lines()
print()
What Python method lets the user read or write to a file?
document()
open()
file()
input()
What will be the output to the console for the code below?
print(3%2 )
2
1
0
3
What will be the output to the console for the code above?
Isabel
Evelyn
Joseph
Chris
What Python method lets the user read or write to a file?
document()
open()
file()
input()
n object of datetime that represents duration or a change in time and is used to calculate future and past times or dates.
timedelta
timediff
timechange
delta
Python module handles the basic date and time classes for manipulating date and time. For manipulating times & dates together (month, day, year, hour, minute, second, microsecond).
datetime
calendar
time
date
What is the order of resolving scope of a name in a python program?
B E G L
G E B L
L E G B
L B E G
Method the provides 26 different items related to date and time that can be used in a Python program, returns as a string.
datetime
strftime
strptime
dateutil
Method that accepts a string value and a format code that it converts into its' datetime equivalent.
datetime
strftime
strptime
dateutil
Using the strftime() method, which one of the format specifiers below will produce an abbreviated display for the month of the year?
%a
%A
%b
%B
How do we get user input from the keyboard?
input = (What is your name?)
input = What is your name?
output = ("What is your name?")
name=input("What is your name? ")
What will be the output for the code above?
Tue, Jan 04 2022
Tuesday, January 04 2022
Friday, April 01 2022
Fri, Apr 01 22
Using the strftime() method, which one of the format specifiers below will produce a hour (24-hour clock) as a zero-padded decimal number?
%M
%H
%-H
%I
Which of the following is used in Python to calculate ten squared?
What will be the output for the code above?
Wednesday, August 05 1981
Wednesday, Aug 05 1981
Wed, Aug 05 81
Wed, Aug 05 1981
Using the strftime() method, which one of the format specifiers below will produce an abbreviated display for the day of the week?
%a
%A
%b
%B
What will be the output for the code above?
2004-08-29
2004-08-29 00:00:00
08-29-2004 00:00:00
08-29-2004
What will be the output for the code above?
2003-07-15 00:00:00
2003-07-15
07-15-2003 00:00:00
07-15-2003
What will be the output for the code above?
20
22
1
5
For Hours(24 hrs format)
%H
%h
%I
%K
What will be the output for the code above?
10
5
1
01
What will be the output for the code above?
2003-17-20 00:00:00
2003-12-15 00:00:00
2008-12-20 00:00:00
2003-12-20 00:00:00
Python mutable datatypes are ?
list
tuple
set
both list and set
For Minutes we use
%m
%M
%j
%H
What will be the output for the program above?
<class 'tuple'>
<class 'list'>
<class 'set'>
<class 'dict'>
Using the strftime() method, which one of the format specifiers below will produce a hour (12-hour clock) as a zero-padded decimal number?
%M
%H
%-H
%I
What will be the output for the program above?
<class 'tuple'>
<class 'list'>
<class 'set'>
<class 'dict'>
What will be the output of the code below?
x=123.456
print(format(x, ".1f"))
123.5
123.456
123.4
123.45
What will be the output for the program above?
<class 'tuple'>
<class 'list'>
<class 'set'>
<class 'dict'>
What symbol do you use to make a comment in Python?
@
//
<!
#
What will be the output for the following program?
import datetime
date = datetime.datetime(2022,2,16)
offset =datetime.timedelta(days=2)
result = date + offset
time_data =result.strftime("%A")
print(time_data)
February
18
2022
Friday
What will be the output of the code below?
x=123456789
print(format(x, "e"))
123456789
123456789.00
1.234568e+08
1.234560e+05
Does python make a distinction between integers and floating variables?
Yes
No
What will be the output of the code below?
x=123456789
print(format(x, ",d"))
123456789
123,456,789
123_456_789
123456789.00
What will be the output of the code below?
x=0.78
print(format(x, "%"))
78%
78.0%
78.000%
78.000000%
When using the open() function which mode will allow the user to open a file for appending, which will also create the file if it does not exist?
open("file", "mode")
"r"
"a"
"w"
"x"
What will be the output of the code below?
x=123456789
print(format(x, "_d"))
123456789
123,456,789
123_456_789
123456789.00
When is the finally block executed?
when an exception occurs
when no exception occurs
never
always
What will be the output of the code below?
x=0.78
print(format(x, ".2%"))
0.78%
78.0%
78.00%
78.000000%
When using the open() function which mode will allow the user to open a file for appending, which will also create the file if it does not exist?
open("file", "mode")
"r"
"a"
"w"
"x"
What will be the output of the code below?
x=0.78
print(format(x, "f"))
0.780000
0.78
78
78.00
When using the open() function which mode will allow the user to open a file for writing, creates the file if it does not exist?
open("file", "mode")
"r"
"a"
"w"
"x"
Can one except block handle multiple exceptions?
Yes
No
May be
Insufficient information
Do you agree with the statement: "Python is a statically typed language."
No - it is dynamically typed
Yes - it is indeed statically typed
When using the open() function which mode will allow the user to creates the specified file, returns an error if the file exists?
open("file", "mode")
"r"
"a"
"w"
"x"
How many except statements can a try-except statement have?
None
One
Two
Multiple
When using the open() function which mode will allow the user to open a file for updating (reading and writing)?
open("file", "mode")
"r"
"r+"
"w"
"x"
When will the else part of try-except-else be executed?
always
when an exception occurs
when no exception occurs
never
When using the open() function which mode will allow the user to open a file for reading, error if the file does not exist?
open("file", "mode")
"r"
"a"
"w"
"x"
What will be the output of the code above?
ADGJMPSVY
ABCDEFGHIJKLMNOPQRSTUVWXYZ
ACEGIKMOQSUWY
AEIMQ
What will be the output of the code above?
ADGJMPSVY
ABCDEFGHIJKLMNOPQRSTUVWXYZ
ZYXWVUTSRQPONMLKJIHGFEDCB
ZYXWV
What will be the output of the code above?
['a', 'b', 'c', 'd', 'e']
['e', 'd', 'c', 'b', 'a']
['a', 'c', 'e']
['e', 'c', 'a']
What will be the output of the code above?
['a', 'b', 'c', 'd', 'e']
['e', 'd', 'c', 'b', 'a']
['a', 'c', 'e']
['e', 'c', 'a']
What type of random numbers will this program print?
All random integers from 0 to 100
All even random integers from 0 to 99
All odd random integers from 0 to 99
All even random integers from 0 to 100
What type of random numbers will this program print?
All random integers from 1 to 100
All even random integers from 1 to 99
All odd random integers from 1 to 99
All even random integers from 1 to 100
What will be stored in variables 'a' after following statements?
perc=(88,85,80,88,83,86)
a=perc[2:-2]
(80,88)
(80,88,83)
(88,80)
(83,88,80)
What will be the output to the console for the code above?
2
4
2
4
6
0
1
2
3
0
1
2
3
4
5
What will be the output to the console for the code below?
print(20 / 2 )
40
4
10
10.0
What will be the output to the console for the code below?
print(45 // 2 )
22.0
90
22
22.5
What will be the output for the code above?
[1, 2, 3, 4, 5]
[1, 3, 4, 5]
[1, 2, 4, 5]
[3, 4, 5]
What will be the output for the code above?
[45, 50, 7, 8, 3, 41]
[45]
[45, 50, 7, 8, 3]
[41, 50, 7, 8, 3, 45]
