二手产品经理

二手产品经理

THIS IS RENO

Learn Python Online in 100 Days - Week 2 Day 3

Due to the May Day holiday, this study has been delayed for a long time. Learning makes me progress, learning makes me happy.

Record#

  1. Review the content of the previous lesson, with decimals as float type, integers as int type.
  2. Calculate using mathematical symbols in Python, + - * / ** % //, addition subtraction multiplication division square remainder quotient.
  3. round function: rounding function.
    round(_number_, _ndigits=None_). Returns the value of _number_ rounded to _ndigits_ decimal places. If _ndigits_ is omitted or None, it returns the integer closest to the input value.
  4. Calculating tips is quite interesting. For someone who has never encountered it before, this calculation method is very strange, no wonder a calculator is needed, haha!

CODE#

print("Tip Calculator")
spend = float(input("How much did you spend? "))
tip = float(input("What percentage do you want to tip? "))
people = int(input("How many people in your group? "))
# owe = round(((spend + tip) / people), 2)

bill_with_tip = tip / 100 * spend + spend
bill_per_person = bill_with_tip / people
owe = round(bill_per_person, 2)

print("You each owe $", owe)

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.