Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added python program for tip calculator - Tipcalculator.py #8120

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Function to calculate the tip
def tip_calc(tip_perc, bill):
return tip_perc * bill / 100

# Function to execute the tip calculation logic
def calculate_tip():
try:
tip_percentage = float(input("Enter the tip percentage: "))
bill_amount = float(input("Enter the amount of the bill: "))

if tip_percentage < 0 or bill_amount < 0:
raise ValueError("Please enter positive values.")

tip_amount = tip_calc(tip_percentage, bill_amount)
total_amount = bill_amount + tip_amount

# Display the results using descriptive sentences without formatting
print("The calculated tip is: " + str(tip_amount) + " rupees.")
print("The total amount to be paid, including the tip, is: " + str(total_amount) + " rupees.")
except ValueError as e:
print("Input Error: " + str(e))

# Start the tip calculation process
calculate_tip()



Loading