WorksheetsPython Basis (S3)
Total questions: 41
Worksheet time: 21mins
How would you assign an integer to a variable?
new_var = int(4)
new_var == 4
new_var = "4"
new var = "4"
How would you print a text string?
output "Hello!"
print ("Hello!")
print (Hello!)
output (Hello!)
What is a variable?
A box (memory location) where you store values
A type of graphics
Data type
A type of memory
What symbol is used in Python to assign values to a variable?
equals =
plus +
forward slash /
asterisk *
What will be the output?
name = 'Dave'
print(name)
Dave
'Dave'
name
(name)
Which is the Python logo?
What is an input?
A function that allows us to ask the user to enter some data.
To plug in something.
Data displayed on a screen.
A function.
What is an output?
A piece of data that is shown on the screen.
Data that the user enters
An output
An orange
What function is used to output a message in Python?
print("")
input=name
name=input
What syntax would you use to create a name variable?
name=input()
input=name
name=input{}
name=INPUT
print(3+4)
print("3+4")
What does the print function do in Python?
It's a variable.
It can input data.
It displays something like a string or integer.
It loops the code.
Which of these is a string?
42
True
"This one!"
No, this one.
How do you define (assign) variables?
var="String"
func==Hello
var : 123
word= Hello
How to create a numeric variable age with a value of 10
age = 10
age = int(10)
age = "10"
In Python, "Hello World" is the same as 'Hello World'
True
False
age = '5'
In the code above, age is a
string
integer
floating point
How do you take input from the user?
input()
scanf()
console()
all of the above
Which is a valid identifier?
0hello
myfile
break
hello world
Improper tab placement will prevent a block of code from running properly.
True
False
A syntax error means your code has a 'grammar' mistake or you used symbols/operations incorrectly.
True
False
Look at the following code, what will it generate?
1,2,3,4,5,6,7,8,9,10,11,12
0,1,2,3,4,5,6,7,8,9,10,11,12
1,2,3,4,5,6,7,8,9,10,11,12,13
0,1,2,3,4,5,6,7,8,9,10,11,12,13
What is the output?
1,2,3,4,5
0,1,2,3,4
1,2,3,4
5,4,3,2,1
How many hallos will be printed?
5
None
4
6
What will be printed after running this FOR loop:
for number in range(6):
print(number)
The number 6
The numbers 0 - 5
The number 5
The numbers 1 - 6
Which of the following programs prints ten lines?
for i in range(10):
print("hi")
for i = 1 to 10:
print("hi")
for i in 1 - 10:
print("hi")
for i from 0 to 9:
print("hi")
What would be the output of the following code:
for i in range(3):
print(5)
0 1 2
3 3 3 3 3
5 5 5
0 1 2 3 4
What would be the output of the following code:
for i in range(3):
print(i)
1 2 3
i i i i
i i i
0 1 2
