Day 2 - Beginner - Understanding Data Types and How to Manipulate Strings

1. Python Primitive Data Types


Data Types

Subscript Example: show "H"

print("Hello" [0])

#Computer counting starts from "0" instead of "1"Math calculation

#Data Type: Integer

Digi 123,456,789 can be written and recognized by the computer as 123_456_789

print(123 + 456)
print(123_111 + 111_123)

#Float

3.14159

BMI Quiz:

Be careful with float and integer (e.g. 1.7m should be float instead of integer)

First Solution:

1. print(int(float(weight)/(float(height)**2)))
2. # 🚨First Error: Mis-type float as integer, so can't run normally 👆
3. # 🚨Second Error: Use integer instead of str [0] str[1] 👆
4. # 🚨Third Error: height*height = height**2 instead of height**height 👆

Final Solution after de-bugging: