0% found this document useful (0 votes)
101 views1 page

Variables and Data Types Practice

The document provides practice problems and solutions related to variables and data types in Python. It includes examples of valid variable names, Boolean values, integers, and floats, along with explanations for each assignment. The solutions demonstrate how to correctly assign and reassign values to variables of different types.

Uploaded by

wannes hela
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
101 views1 page

Variables and Data Types Practice

The document provides practice problems and solutions related to variables and data types in Python. It includes examples of valid variable names, Boolean values, integers, and floats, along with explanations for each assignment. The solutions demonstrate how to correctly assign and reassign values to variables of different types.

Uploaded by

wannes hela
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

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

You might also like