Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Variables -Day 3

Total questions: 32

Worksheet time: 16mins

Name
Class
Date
1.

What is a variable?

a)

programming

b)

storage location

c)

value

d)

variable name

2.

A Variable consists of...

a)

VariableName and Value

b)

Storage Location

c)

IPO Chart and Flowchart

d)

Programs

e)

Algorithms

3.

Which one is true:

a)

Variables can change

b)

Values can change

c)

VariableNames can change

d)

Data Types can change

4.

Which one is true:

a)

Values cannot change

b)

Variable Name

c)

Data Type

d)

A variable can only hold one value at a time

5.

Select all that are true for creating a VariableName

a)

no spaces

b)

start with a letter

c)

each word starts with a capital letter

d)

can only be a single word

e)

same name used throughout

6.

This programming concept allows programmers to create storage for data?

a)

Control Strucutures

b)

Variables

c)

Selection Structures

d)

Logic Operators

7.

This operator assigns values. It also looks like an equal sign.

a)

The boolean operator

b)

The selection structure

c)

The assignment operator

d)

The logic operator

8.
Variables cannot be changed.
a)
False
b)
True
9.

Which of this lines show the correct way to reassign a variable to a new value?

a)

ironMAN=1000;

b)

1000->ironMAN;

c)

var ironMAN=1000;

d)

1000 = ironMAN;

10.

What is a variable?

a)

A number that represents a shape

b)

A letter that represents a number

c)

A letter that represents a letter

d)

I dont know

11.

If t=5, what is 6+t

a)

10

b)

9

c)

7

d)

11

12.

If p=7 What is px10

a)

70

b)

80

c)

60

d)

77

13.

What are variables?

a)

They are containers to store values of data.

b)

They are a method to analyze data.

c)

They are some commands.

d)

They are names of types of data.

14.
Variable names can't start with a number.
a)
True
b)
False
15.
Variable names can include spaces.
a)
False
b)
True
16.

In computers science, variables:

a)

are numbers like pi

b)

represent parts of an experiment that are measured or tested

c)

are placeholders for storing information

d)

are unchangeable

17.

Can I name my variable: Player1

a)

True

b)

False

18.

I can name my variable: player 1 is the winner

a)

True

b)

False

19.

I can name my variable: Player_1_is_the_best

a)

True

b)

False

20.

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

21.

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

22.

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

23.

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

a)

name

b)

teacher

c)

mister

d)

abcdef

24.

What rule is the following variable name BREAKING:


1st_Name

a)

No special characters other than underscore

b)

Only use text for the start of the variable name - no numbers at start

c)

Keep names meaningful

d)

There is nothing wrong with this variable name

25.

What rule is the following variable name BREAKING?


StudentNo.

a)

Only use text for the starting letter of a variable name - not numbers at the start

b)

No special symbols other than the underscore

c)

There is nothing wrong with this variable name

d)

Keep variable names meaningful for the task they are being used for

26.

what is the variable name in the following script?

a)

name

b)

hello, your name is

c)

print

d)

There is no variable in this script

27.

Which name would be meaningful in keeping a record of someone's high score?

a)

s

b)

hs

c)

score

d)

highScore

28.

Which of the below are acceptable variable names?

a)

result final = 5

b)

result-final = 1

c)

resultFinal = 3

d)

result#final = 4

29.

What is a variable?

a)

A location in memory that temporarily stores a value that your program can use later.

b)

Data type

c)

An ordered collection of items which can be of any data type

d)

It is a command(function)

30.

What is Python syntax for creating a variable and assigning the number 10 to it?

a)

variable_name == 10

b)

variable_name = 10

c)

variable name = 10

d)

def variable-name = 10

31.

What happens when running the following code?


message = what a cool message!

print(message)

a)

Python throws a SynthaxError because the string is not surrounded by quotes.

b)

Python throws a NameError because the name is not defined properly.

c)

“message” is printed.

d)

“What a cool message!” gets printed to the console.

32.

These are all valid variable names and assignments, EXCEPT:

a)

user_name = “jdoe”

b)

prompt21 = “Enter your user name”

c)

43agents = False

d)

userID = 100