Variables
# Set name to a value
name = "Bob"
print(name)
# Set value for name_length variable
name_length = 3
# Multiple assignments
name, name_length = "Bob", 3
# Print variable type
print(type(name))
print(type(name_length))
# Explicitly make the value an integer
name_length = int("4")
print(type(name_length))
# This will give you an error
name = int("neut")
# Declares list data type
name_list = ["Bob", "Jane", "Mike"]
print(type(name_list))
# Assign values to variables form a list data type
name1, name2, name3 = name_list
print(name1)
print(name2)
print(name3)
# Create a tuple
name_tuple = ("Bob", "Jane")
print(type(name_tuple))
# Create dictionary data type
name_dictionary = {"Bob": 4, "Jane": 6}
print(type(name_dictionary))
# Create a boolean data type
name_boolean = True
print(type(name_boolean))
# Create a range data type
name_range = range(6)
# Create a bytes data type
name_bytes = b"Bob"
print(type(name_bytes))
Last updated