WorksheetsPython Basics-02
Total questions: 21
Worksheet time: 32mins
Name the first variable in this code
(a)
What key term in python allows the user to answer a question
(a)
Name the programming error which is a grammatical error
(a)
If you have a syntax error will the code run?
Yes
No
print("3+4")
What will the output be from the following code?
a = 5
b = 6
print((a > 2) and (b > 6))
True
False
Error
56
"def" keyword is used in python to-
def is a variable
define a new conditional variable
use conditional
define a new function
How do you create a variable with the floating number 2.8?
x=2.8
x=float(2.8)
both are correct
How do you create a variable with the numeric value 5?
Both are correct
x=5
x=int(5)
// means:
two times division
integer division
exact division with floating number
Put a slash
Which of the following pieces of code defines a list of all the numbers from 4 to 12?
range(4,12)
range(4, 13)
range( 3,12)
range(3, 13)
A line of text that Python won't try to run as code
Integer
Comment
Strings
Input
Which of these would work as a piece of code?
if string="Dove"
if string=="Dove"
IF string="Dove":
if string=="Dove":
cakeAmount = input()
print "We have", cakeAmount, " cakes"
The above code is run. You type: Six
Select the correct output.
We have 6 cakes
We have six cakes
Error
x = 5
y = 6
print(x*y)
Select the correct answer(s):
x is a variable
x is a value
print() is a funciton
age = 16
message = "my age is: "
print (message, age)
Select the correct answer(s) below:
the output would read:
my age is 16
age is a variable
16 is assigned to the age variable
Examine the code below. On which line of code will there be an error?
weight = input("How much do you weigh? ")
oz_water = weight / 2
print("You should drink " + str(oz_water))
print("ounces of water every day if you weigh " + weight)
Line 1
Line 2
Line 3
Line 4
What is the appropriate symbol(s) used for modulus in Python?
%
#
"""
"""
//
What is the best way to get a number from the user to use in a calculation?
num = str(input(“Enter a number: “))
num = number(input(“Enter a number: “))
num = input(“Enter a number: “)
num = int(input(“Enter a number: “))
