二手产品经理

二手产品经理

THIS IS RENO

Learn Python Online in 100 Days - Week 2, Day 3

Because of 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 class. Numbers with decimal points are float types. Integers are int types.
  2. Perform calculations using mathematical symbols in Python: + - * / ** % //. Addition, subtraction, multiplication, division, exponentiation, modulus, floor division.
  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 nearest integer to the input value.
  4. Calculating tips is 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.