Python: Declaring Datatypes - # 2
Posted: Thu Apr 30, 2026 2:45 pm
Declaring Datatypes (First Method)
Here is a second way to declare datatypes. Data types don't need to be declared, but can be for clarity and/or to eliminate confusion in the program that could lead to errors.
Code: Select all
name: str = "Amber"
Amber_GPA: float = 3.5
Amber_age: int = 20
Amber_has_double_major: bool = False
Amber_changeable_class_group: list = ['Chemistry', 'American Literature', 'Calculus']
Amber_unchangeable_doctor_appointments: tuple = ('Saturday', 'Monday', 'Tuesday')
Amber_pick_of_certain_numbers: set = {1, 8, 10, 11}
Amber_doctor_appointments_in_detail: dict = {'Saturday': '4th', 'Monday: 6th', 'Tuesday: 7th'}