Variables And Data Types Practice Problems
Solutions:
Paste everything below this into “[Link]” to get
the correct format:
# Removing the 9 from 9variableNamesCannotBeginWithANumber gives variableNamesCannotBeginWithANumber,
a valid variable
# name.
variableNamesCannotBeginWithANumber = True
initial = 3
# There are only 2 Boolean values: True and False. Since True was assigned to the variable
# "variableNamesCannotBeginWithANumber", and we want a different boolean value to be assigned to the variable
# "boolean", boolean must be assigned the value False.
boolean = False
# I chose to give posInt the value 7, but you could have assigned it any positive integer you wanted such as 1, 1000,
# 1000000, 23498, etc.
posInt = 7
zero = 0
# I chose to assign negFloat the value -3.9, but you could have given it any decimal number less than zero: -3.0,
-34.8,
# -23487.9787, etc.
negFloat = -3.9
# You could have reassigned the variable "initial" any value of any of the types you have been shown:
# An integer such as: 1, 9, 156, or -5
# A float such as: 4.1148, .001138, or -.42
# A boolean value: either True or False
initial = 18