-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDay 13 - your_vat.py
36 lines (28 loc) · 1.15 KB
/
Day 13 - your_vat.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
"""
Created on Tue Aug 13 2024
@author: GRACE ESTRADA
Day 13 of 50 Days of Python
Write a function called your_vat.
The function takes no parameter.
The function asks the user to input the price of an item and VAT (vat should be a percentage).
The function should return the price of the item plus VAT.
If the price is 220 and, VAT is 15% your code should return a vat inclusive price of 253.
Make sure that your code can handle ValueError.
Ensure the code runs until valid numbers are entered. (hint: Your code should include a while loop)
"""
def your_vat():
while True:
try:
price = 0
price = input("Please enter the price of your product (or type 'exit' to quit): ")
if price.lower() == 'exit':
print('Exiting the program. Thank you!')
break
else:
price = int(price)
vat = int(input("Please input vat percentage (in %): "))
price_vat_inc = round(price * (1 + (vat/100)), 2)
print(price_vat_inc)
except:
print("Please enter a numeric value")
your_vat()