PYTHON VARIABLES AND DATA TYPES
Before this unit, I thought the word name in my code was just a word. Now I have learned that every variable has two parts: the name (the label on the box) and the value (what is inside the box). In name = "DSGBOY", name is the label and "DSGBOY" is the value.
What became clear: print(name) shows the value inside the box, but print("name") shows the word name itself, because of the quotes. One pair of quotes completely changed the output, and that is when the difference between a variable's name and its value finally made sense to me.
I also learned that every value has a data type: str for text, int for whole numbers and float for numbers with a decimal point. Using type() let me ask Python what kind of box each variable was.
The data type that felt most natural to me was str. Names, favorite colors and subjects are how I normally describe myself, and I could see them clearly inside the quotes. int felt easy too. float needed more care, because the decimal point decides whether Python treats 1.5 as a float or not.
Which data type felt most natural to you, and why?
#variable #data type #learned
