Bill Inputs

image of a cartoon money
image of a hand giving a tip
image of a cartoon person
bill_total_input = Element("bill_total_input") tip_percent_input = Element("tip_percent_input") number_of_people_input = Element("number_of_people_input") bill_total_display = Element("bill_total_display") tip_percent_display = Element("tip_percent_display") each_person_pays_display = Element("each_person_pays_display") op1 = Element("tip_percent_display") op2 = Element("each_person_pays_display") op3 = Element("bill_total_display") def reset_btn(*args, **kwargs): bill_total_input.clear() tip_percent_input.clear() number_of_people_input.clear() def calculate_btn(*args, **kwargs): tip_amount = float(bill_total_input.value) * int(tip_percent_input.value) / 100 op1.write(f"{tip_amount:.2f}") bill_total_display = float(bill_total_input.value) + float(tip_amount) op3.write(f"{bill_total_display:.2f}") each_person_pays_display = bill_total_display / int(number_of_people_input.value) op2.write(f"{each_person_pays_display:.2f}")

Bill Breakdown

image of a cartoon money
image of a hand giving a tip
image of a cartoon person

Tip Calculator developed by Stephen Mc Govern

View My Portfolio | View My Github

Copyright© 2022 | All rights reserved