NEW
Font size
WorksheetsPython review 1(Y7)
Total questions: 21
Worksheet time: 11mins
Which of the following is a command to have a message appear on the screen?
write
msg
input
Pick the Python command used to make the user type in some data (input the data)
get
input
int
float
print(Hello world!)
Which of the following is used in Python to give a value to a variable
:=
==
=
Which one is NOT a valid variable name?
my_var
myvar
_myvar
my var
What will be the output when a user enters WILLIAM
name = input("Enter your name: ")
print("Hello, " + name)
Hello name
Hello William
Helloname
Hello WILLIAM
print("Hello world!\nHello world!")
Hello world!
What part of an if statement should be indented?
All of it
The statements within it
the first line
the lines within the brackets
Look at the following code:
name = "John"
age = 23
What type of data is stored in the variable name?
str
int
float
nothing
Look at the following code:
name = "John"
age = 23
What type of data is stored in the variable age?
str
int
float
nothing
If I want to store my height in a variable, which of the following would be a good variable name in best practice?
abcdefg
inches
number
height
If I want to store multiple names in variables, which of the following would be good variable names in best practice?
a
b
c
name1
name2
name3
Audrey
Ben
John
blah1
blah2
blah3
Look at the following code:
age = "23"
age = int(age)
What does the int() function do to the data in my variable?
does nothing
changes the string to a float
changes the number to a string
changes the string to an integer
Look at the following code:
age = 23
age = float(age)
What does the float() function do to the data inside age?
changes the string to an int
changes the int to a string
adds a decimal point (23.0)
does nothing
float, integer, and string are all examples of what?
Words
Variables
Concatenation
Data Types
holds whole numbers
holds a decimal point in a number
