Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
April 2, 2022 10:09 am GMT

100 Days of Code: The Complete Python Pro Bootcamp for 2022 - Day 2

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)

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)

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.")

Project Day 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 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} ")


Original Link: https://dev.to/mike_kameta_aed62d48c2d0f/100-days-of-code-the-complete-python-pro-bootcamp-for-2022-day-2-71f

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To