NEW
Font size
S
M
L
XL
WorksheetsPython Basics
Total questions: 16
Worksheet time: 16mins
Name
Class
Date
1.
How would you assign an integer to a variable?
a)
new_var = 4
b)
new_var == 4
c)
new_var = "4"
d)
new var "4"
2.
How would would you print a text string?
a)
output "Hello!"
b)
print ("Hello!")
c)
print (Hello!)
d)
output (Hello!)
3.
Which symbol do we use if we want to add a comment to our code?
a)
@
b)
#
c)
*
d)
&
4.
To create a variable named new_var and assign it a value of 81 divided by 9, which statement would you use?
a)
new_var = 81 \ 9
b)
new_var = "81 / 9"
c)
new_var = "81 \ 9"
d)
new_var = 81 / 9
5.
Choose the statement that assigns 4 to the power of 3 to the variable new_var...
a)
new_var = 4 ** 3
b)
new_var = 3 ** 4
c)
new var = 3 ** 4
d)
new_var = 4 ^^ 3
6.
Which of the following is a float?
a)
new_var = 1234
b)
new_var = True
c)
new_var = 1.234
d)
new_var = "True"
7.
Which of the following is not a string?
a)
new_var = "True"
b)
new_var = "3123"
c)
new_var = "3.123"
d)
new_var = False
8.
Which of the following text strings is correct?
a)
new_var = "Tim/'s Computer"
b)
new_var = "Tim\'s Computer"
c)
new_var = "Tim's Computer"
d)
new_var = Tim's Computer
9.
How would you output new_var = 123 as a text string?
a)
print str(new_var)
b)
print new_var.str
c)
print str[new_var]
d)
print (new_var).str()
10.
Numbers with a decimal point belong to a type called...
a)
pointing
b)
integers
c)
decimal
d)
float
11.
To create a newline at the end of a prompt, you can use which of the following expressions?
a)
\new
b)
\return
c)
\break
d)
\n
12.
A _____________ expression is an expression that is either true or false.
a)
boolean
b)
truth
c)
variable
d)
conditional
13.
Each time the body of a loop is executed, it is called a(n) _______________.
a)
pass
b)
loopy
c)
iteration
d)
lap
14.
What is the output from this program?
a)
5
7
9
A python is a non-venomous snake
done
7
9
A python is a non-venomous snake
done
b)
A python is a non-venomous snake
A python is a non-venomous snake
A python is a non-venomous snake
done
A python is a non-venomous snake
A python is a non-venomous snake
done
c)
A python is a non-venomous snake
A python is a non-venomous snake
A python is a non-venomous snake
A python is a non-venomous snake
done
A python is a non-venomous snake
A python is a non-venomous snake
A python is a non-venomous snake
done
d)
done
15.
What does an IF statement do?
a)
Closes the program
b)
Makes a decision
c)
Asks a question
16.
Which of these would be used to loop through instructions a set number of times?
a)
IF statement
b)
WHILE loop
c)
FOR loop
Reset
