wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Python review 1(Y7)

Total questions: 21

Worksheet time: 11mins

Name
Class
Date
1.

Which of the following is a command to have a message appear on the screen?

a)

print

b)

write

c)

msg

d)

input

2.

Pick the Python command used to make the user type in some data (input the data)

a)

get

b)

input

c)

int

d)

float

3.
What will the output be from the following code?
print(Hello world!)
a)
Hello world!
b)
SyntaxError
c)
Hello world
d)
print(Hello world!)
4.

Which of the following is used in Python to give a value to a variable

a)

:=

b)

==

c)

=

5.

Which one is NOT a valid variable name?

a)

my_var

b)

myvar

c)

_myvar

d)

my var

6.

What will be the output when a user enters WILLIAM


name = input("Enter your name: ")

print("Hello, " + name)

a)

Hello name

b)

Hello William

c)

Helloname

d)

Hello WILLIAM

7.
Why do we use variables in programming?
a)
edit data
b)
store data
c)
integer
d)
to look good
8.
What will the output be from the following code?
print("Hello world!\nHello world!")
a)
Hello world! Hello world!
b)
Hello world!
Hello world!
c)
SyntaxError
d)
Hello world!
9.
Joining elements together to make a string is called what?
a)
Combining
b)
Connecting
c)
Concatenation
d)
Stringing
10.

What part of an if statement should be indented?

a)

All of it

b)

The statements within it

c)

the first line

d)

the lines within the brackets

11.

Look at the following code:

name = "John"

age = 23

What type of data is stored in the variable name?

a)

str

b)

int

c)

float

d)

nothing

12.

Look at the following code:

name = "John"

age = 23

What type of data is stored in the variable age?

a)

str

b)

int

c)

float

d)

nothing

13.

If I want to store my height in a variable, which of the following would be a good variable name in best practice?

a)

abcdefg

b)

inches

c)

number

d)

height

14.

If I want to store multiple names in variables, which of the following would be good variable names in best practice?

a)

a

b

c

b)

name1

name2

name3

c)

Audrey

Ben

John

d)

blah1

blah2

blah3

15.

Look at the following code:

age = "23"

age = int(age)


What does the int() function do to the data in my variable?

a)

does nothing

b)

changes the string to a float

c)

changes the number to a string

d)

changes the string to an integer

16.

Look at the following code:

age = 23

age = float(age)


What does the float() function do to the data inside age?

a)

changes the string to an int

b)

changes the int to a string

c)

adds a decimal point (23.0)

d)

does nothing

17.

float, integer, and string are all examples of what?

a)

Words

b)

Variables

c)

Concatenation

d)

Data Types

18.
In python the ' STRING data type' can be defined as...?
a)
holds alphanumeric text
b)
hold whole numbers
c)
holds numbers with a decimal point
d)
holds either a true or false value
19.
In python the ' FLOAT data type' can be defined as...?
a)
holds alphanumerical data
b)

holds whole numbers

c)

holds a decimal point in a number

d)
hold either true or false
20.
what is correct code for INTEGER in python?
a)
in
b)
ing
c)
int
21.
Which of the following is a float?
a)
new_var = 1234
b)
new_var = True
c)
new_var = 1.234
d)
new_var = "True"