NEW
Font size
Worksheets/Python_Quiz\
Total questions: 20
Worksheet time: 20mins
Which Python code segment will display "Hello, world!" on the screen?
display Hello, world!
print("Hello, world!")
print "Hello, world!"
"Hello, world!"
What type is the following variable? x = "Hi there"
float
integer
boolean
string
What does the following Python program print? x = 12 % 4 print(x)
0
1
3
4
middle age
Young age or middle age
Young age
"Young age or middle age"
Young age
Middle age
Slightly old
Very old
1
3
5
7
9
2
4
6
7
9
1
2
3
4
5
10
9
8
7
6
5
num= [34,56,78,12]
num.append(75)
print(num)
[34,56,,75]
[34,56,]
[34,56,78,12,75]
[34,2,75]
list.remove(element)
num= [1,2,3,4,5,6,7]
print(num.remove(4))
[1,2,3,5,6,7]
[1,2,3,5,7]
[1,2,3,6,7]
[1,,3,5,6,7]
list.reverse()
num= [2,3,4,5,6]
print(num.reverse())
[2,3,4,5,6]
[6,5,7,2]
[6,3,2]
[6,5,4,3,2]
Comments are:
for humans to read and understand
needed when a program is over 50 lines
commands that are performed by the computer
ALWAYS blue
How do you begin a one-line comment?
*
#
+
"
Which is the best variable name?
Draw_Two_Squares
draw_squares
2_squares
Why do we use if statements?
to stop our code if there's an error
so the computer will make decisions based on conditions
to run a command
to run one function at a time
Why do we use while loops?
To repeat code a specific number of times
To use if-else statements in a loop
To repeat code when the number of times to repeat is unknown
To determine if a condition is true
What will this output print( 3 + 4 * 5)
23
35
3+4*5
Nothing it will give an error
Identify the type
num=(1,3,5,7,9,3,4)
Tuple
List
Dictionary
keys
Founder of Python?
Guido van Rossum
Tim Berners Lee
Charles Babbage
None of them
What type of Language is Python?
Machine Language
Assembly Language
High level Language
None of them
Which is Python Keyword?
Apple
input
john
number
Is Python case sensitive when dealing with identifiers?
a) yes
b)no
c) machine dependent
d) none of the mentioned
