Variables Practice Text Version


Slide 1

Naming Variables

 

Slide 2

Naming Variables

On the following slides, you will practice choosing good variable names.  Remember, variable names should describe the value.  Type Mismatch errors are common when working with variables.  Always make sure the TYPE of variable matches the TYPE of value.

 

Slide 3

Question: 1

Which variable should be used
to represent a person’s age
?


Which variable name is more meaningful?

A = a
B = age

 

Slide 4

Question: 2

Which variable should be used to
represent the name of an employee?

Which variable name is more meaningful?

A = employee$
B = e$

 

Slide 5

Question: 3

Which variable should be used to
represent the volume of a cube?

Which variable name is more meaningful?

A = c
B = v
C = cube
D = volume

 

Slide 6

Question: 4

Which variable should be used to
represent the title of a movie?

Which variable name is more meaningful?

A = m$
B = t$
C = movie$
D = title$

 

Slide 7

Question: 5

The number of laps run by Spencer

Which variable should you use?

A = laps
B = lap$

 

Slide 8

Question: 6

An employee named Mike

Which variable should you use?

A = Mike
B = Mike$
C = employee$

 

Slide 9

Question: 7

Fortune 500 company named
..........Computer’s Inc.

Which variable should you use?

A = company$
B = 500company$
C = computer$
D = company

 

Slide 10

Question: 8

The number of butterflies, ants, and bees
.................observed in a garden

Which variable should you use?

A = butterfly, ant, bees
B = insect1, insect2, insect3

 

Slide 11

Question: 9

Names of major league baseball
...................... pitchers

Which variable should you use?

A = pitcher1, pitcher2, pitcher3
B = pitcherA$, pitcherB$, pitcherC$
C = pitcher1$, pitcher2$, pitcher3$

 

Slide 12

Question: 10

LET car = “Hummer”

Will an error result?

A = no error
B = Type Mismatch error

 

Slide 13

Question: 11

LET car$ = “Hybrid”

Will an error result?

A = no error
B = Type Mismatch Error

 

Slide 14

Question: 12

LET number = 1

Will an error result?

A = no error
B = Type Mismatch Error

 

Slide 15

Question: 13

LET number$ = “1”

Will an error result?

A = no error
B = Type Mismatch Error

 

Slide 15

Question: 14

LET number$ = 1

Will an error result?

A = no error
B = Type Mismatch Error

 

Slide 16

Naming Variables

If you have any questions about assigning values to variables, please contact your instructor.

Remember the TYPE of variable (string or numeric) must match the TYPE of value (alphanumeric or numeric).  Also, choose a variable name that describes the value.

Show Examples:
LET one = 1
LET message$ = “You are number”
PRINT message$;one

Check Your Answers

 

previous