Font size
WorksheetsBasics Python
Total questions: 20
Worksheet time: 10mins
Which commands might be correct? (Multiple answers)
random. random(1, 10)
print(random.random( ))
print(random. randint(1,10))
import.random(2.7)
How do you define(assign) variables?
var="String"
func==Hello
var : 123
word= Hello
Which one does take you to next line?
\t
\n
/n
\\
What is the word (command) used to display numbers and text on the screen?
Input
Output
Command
What symbol is used in python to assign values to a variable?
:
*
=
==
Which of these would work as a piece of code?
if string="Dove"
if string=="Dove"
IF string="Dove":
if string=="Dove":
What is the end after if statements?
if
Elif
Else
While
Which of the following is a correctly-formatted comment?
*Comment
"Comment"
#comment
(comment)
A line of text that Python won't try to run as code
Integer
Comment
Strings
Input
A data type than can have one of two values: True or False
Boolean
Basic Calculation
For
While
Data type for a whole number
Float
Boolean
Integer
String
A Python data type that holds positive and negative whole numbers
String
int
str
input
The Boolean operator that returns true if EITHER of its operands are true
and
or
not
equal
print(boolean(None, "String", False, "False", 0,"value")
What is the output?
False, True, True, False, False, True
False, True, False, True, False, True
True, True, False, False, True, False
False, False, True, True, False, True
Which of the following sequences would be generated by the given line of code?
range (10, 0, -5)
10,9,8,7,6,5
10, 5
0, 5, 10
10, 5, 0
In a Python program, what would be the increment value for the looping variable in the FOR LOOP code?
for x in range (25, 10, -5)
10
-5
25
5
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)
// means:
two times division
integer division
exact division with floating number
Put a slash
What does symbol % do?
Integer exact division
Percentage
Division
Remainder
What does "\t " make?
Goes to next line
Horizontal space between two strings
Give a title
Add a slash
