100일 간의 코드: 2022년을 위한 완전한 Python Pro 부트캠프 - 2일차(팁 계산기)

7015 단어
연습 1 - 데이터 유형

#🚨 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)


연습 2 - BMI 계산기

#🚨 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)


연습 3 - 몇 주 동안의 삶

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


프로젝트 2일 차 - 팁 계산기

#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} ")

좋은 웹페이지 즐겨찾기