Day 2 - Data Type & Calculate


Posted by pei_______ on 2022-04-13

learning from 100 Days of Code: The Complete Python Pro Bootcamp for 2022


Data Type : int( ) / float( ) / str( )

Type Checking : type( )

Type Error : input( ) = string 、 f string = print(f"{ }")

Calculate / round( 1.666666 , 2) = 1.67

# BMI Calculator
height = input("enter your height in m: ")
weight = input("enter your weight in kg: ")

w = int(weight)
h = float(height)
print(int(w/h**2))

# Life in Weeks
age = input("What is your current age?")

x =(90- int(age))*365
y =(90- int(age))*52
z = (90- int(age))*12

print(f"You have {x} days, {y} weeks, and {z} months left.")

# tip-calculator
print("Welcome to the tip calculator!")
pay = float(input("What was the total bill? $"))
tip = int(input("How much tip would you like to give? 10, 12, or 15? "))
person = int(input("How many people to split the bill?"))

bill = pay * ((tip/100)+1) / person
bill_final = round(bill, 2)

print(f"Each person should pay: $ {bill_final}")

#Python #課堂筆記 #100 Days of Code







Related Posts

5.  SpringBoot使用jms錯誤處理延(1)

5. SpringBoot使用jms錯誤處理延(1)

【閱讀】注意力商人:他們如何操弄人心?揭密媒體、廣告、群眾的角力戰

【閱讀】注意力商人:他們如何操弄人心?揭密媒體、廣告、群眾的角力戰

【 JavaScript 學習筆記 】Hoisting  變數提升及 暫時性死區(TDZ)

【 JavaScript 學習筆記 】Hoisting 變數提升及 暫時性死區(TDZ)


Comments