Advertisement
bacnguyenxgen

Untitled

Oct 1st, 2022
708
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.43 KB | None | 0 0
  1. def main():
  2.     dollars = dollars_to_float(input("Bữa ăn có giá bao nhiêu? "))
  3.     percent = percent_to_float(input("Tỉ lệ phần trăm bạn muốn boa là bao nhiêu? "))
  4.     tip = dollars * percent
  5.     print(f"Hãy boa ${tip:.2f}")
  6.  
  7.  
  8. def dollars_to_float(d):
  9.     a = d.replace("$","")
  10.     b = float(a)
  11.     return b
  12.  
  13.  
  14. def percent_to_float(p):
  15.     c = p.replace("%","")
  16.     d = float(c)
  17.     return d/100
  18.  
  19.  
  20. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement