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
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:
1. # 🚨 Don't change the code below 👇
2. height = input("enter your height in m: ")
3. weight = input("enter your weight in kg: ")
4. # 🚨 Don't change the code above 👆
5.
6. #Write your code below this line 👇
7.
8. height_s = float(height)
9. weight_s = float(weight)
10. BMI = weight_s/(height_s * height_s)
11. print(str(BMI)[0] + str(BMI)[1])
12.
13. # 🚨Above Error: Should use integer instead of str [0] str[1],
14. which will cause an error if the result is 2.0 (became 2. instead of 2) 👆