DEV Community

mikekameta
mikekameta

Posted on

100 Days of Code: The Complete Python Pro Bootcamp for 2022 - Day 2 (Tip Calculator)

Exercise 1 Data Types

#🚨 Don't change the code below πŸ‘‡
two_digit_number = input("Type a two digit number: ")
#🚨 Don't change the code above πŸ‘†

####################################
#Write your code below this line πŸ‘‡
first_digit = two_digit_number[0]
second_digit = two_digit_number[1]
int_first_digit = int(first_digit)
int_second_digit = int(second_digit)
result = int_first_digit + int_second_digit
print(result)
Enter fullscreen mode Exit fullscreen mode

Exercise 2 BMI Calculator

#🚨 Don't change the code below πŸ‘‡
height = input("enter your height in m: ")
weight = input("enter your weight in kg: ")
#🚨 Don't change the code above πŸ‘†

#Write your code below this line πŸ‘‡
bmi = int(weight) / float(height) **2
bmi_int = int(bmi)
print(bmi_int)
Enter fullscreen mode Exit fullscreen mode

Exercise 3 Life in Weeks

#🚨 Don't change the code below πŸ‘‡
age = input("What is your current age?")
#🚨 Don't change the code above πŸ‘†

#Write your code below this line πŸ‘‡
days = 90 * 365 - int(age) * 365
weeks = 90 * 52 - int(age) * 52
months = 90 * 12 - int(age) * 12

print(f"You have {days} days, {weeks} weeks, and {months} months left.")
Enter fullscreen mode Exit fullscreen mode

Project 2 Tip Calculator

#If the bill was $150.00, split between 5 people, with 12% tip. 
#Each person should pay (150.00 / 5) * 1.12 = 33.6
#Format the result to 2 decimal places = 33.60

#Tip: There are 2 ways to round a number. You might have to do #some Googling to solve this.πŸ’ͺ

#Write your code below this line πŸ‘‡
print("Welcome to the tip calculator")
bill = int(input("How much is your bill? $ "))
tip = int(input("How much tip do you want to leave? 10, 12 or 15 percent? "))
people = int(input("How many people will split the bill? "))
bill_with_tip = tip / 100 * bill + bill
split = (bill_with_tip / people)

#Note - The round function did not produce the result asked so had #to change it the below. Thank you google lol

total_bill_split = "{:.2f}".format(split)
print(f"Each person should pay ${total_bill_split} ")
Enter fullscreen mode Exit fullscreen mode

Top comments (0)