Day 2 – Understanding Data Types

Day 2 itinerary:

  • Day 2 Goals
  • Primitive Data Types
    • Type Error
    • Type Checking
    • Type Conversion
  • Mathematical Operators in Python
  • Coding Exercise: BMI Calculator
  • Number Manipulation and F Strings in Python
  • Project: Tip Calculator

Here is my BMI Calculator

# The values are hard coded because Udemy won't allow inputs
# also we havent discussed inputs yet

height = 1.65 
weight = 84

# Calculate the bmi using weight and height.
bmi = weight / height ** 2

print(bmi)

Here is my Tip Calculator

print("Welcome to the tip calculator!")
bill = float(input("What was the total bill? $"))
tip = int(input("What percentage tip would you like to give? 10 12 15 "))
people = int(input("How many people to split the bill? "))

total_bill = bill + (bill * (tip / 100))
bill_per_person = total_bill / people
final_amount = round(bill_per_person, 2)
print(f"Each person should pay: ${final_amount}")