-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTutorial2.py
121 lines (88 loc) · 3.57 KB
/
Tutorial2.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#Question 1
#Prompt user to enter the number of videos and oldies purchased
Number_Videos = int(input("Number of videos:"))
Number_Oldies = int(input("Number of Oldies:"))
Number_days = int(input("Number of days:"))
#Calculate the total charge for customer's video rental.
Total_charge = (((Number_Videos * 3.00) + (Number_Oldies * 2.00)) * Number_days)
#Print the total cost
print(f"Total cost is {Total_charge:.2f}")
#Question 2
#Prompt user to enter the time for an event in seconds
seconds = float(input("Time of event in seconds:"))
#Calculate hours
hours = seconds // 3600
remains = seconds - (3600 * hours)
#Calculate minutes
minutes = remains // 60
seconds = remains % 60
#Print out the time in hours, minutes and seconds
print(f"{hours:.0f}:{minutes:.0f}:{seconds:.0f}")
#Question 3
#Prompts user to enter his/her yearly income
yearly_income = float(input("Yearly income:"))
#If user's yearly income is between 0 and 2500, tax is 0
if yearly_income >= 0.0 and yearly_income <= 2500.0:
tax = 0
print(f"Amount of taxes to pay: {tax:.2f}")
#If user's yearly income is betweem 2501 and 10000, user has to pay 5% tax
elif yearly_income > 2500.0 and yearly_income <= 10000.0:
tax = yearly_income * 0.05
print(f"Amount of taxes to pay: {tax:.2f}")
#If user's yearly income is between 10001 and 50000, user has to pay 15% tax
elif yearly_income > 10000.0 and yearly_income <= 50000.0:
tax = yearly_income * 0.15
print(f"Amount of taxes to pay: {tax:.2f}")
#If user's yearly income is more than 50000, user needs to pay 25% tax.
else:
tax = yearly_income * 0.25
print(f"Amount of taxes to pay: {tax:.2f}")
#Question 4
#Prompt user to enter their monthly data usage
Monthly_usage = float(input("Monthly data usage in GB:"))
#Calculate and print the data charge for the month
if Monthly_usage <= 10.0:
Charge = Monthly_usage * 15
print(f"Data charges for the month is:{Charge:.2f}")
else:
Charge = Monthly_usage * 30
print(f"Data charges for the month is:{Charge:.2f}")
#Question 5
#Prompt user to choose R/r or C/c
Shape = input("Select rectangle or circle:")
#Calculate area of rectangle or area of circle
#If user inputs R or r, it will calculate and print the area of rectangle
if Shape == "R" or Shape == "r":
length = float(input("Length of rectangle:"))
width = float(input("Width of rectangle:"))
area = length * width
print(f"Area of rectangle is {area:.2f}")
#If user inputs C or c, it will calculate and print the area of circle
elif Shape == "C" or Shape == "c":
PI = 3.14159
radius = float(input("radius of circle:"))
area = (PI * (radius**2))
print(f"Area of circle is {area:.2f}")
else:
print("Please enter R or r or C or c")
#Question 6
#Prompt user to enter day of the week in number
day = int(input("Please enter day of the week in number:"))
#Use match case to print out the output based on the user's input
match day:
case 1:
print(f"The drink of the day is Peppermint Mocha")
case 2:
print(f"The drink of the day is Candy Bar Latte")
case 3:
print(f"The drink of the day is Caramel Coffee")
case 4:
print(f"The drink of the day is Chocolate Almond Cafe Au Lait")
case 5:
print(f"The drink of the day is Pumpkin-Chai Latte")
case 6:
print(f"The drink of the day is Vanilla-Chai Tea")
case 7:
print(f"The drink of the day is Gingerbread Latte")
case _:
print("Please enter values from 1 to 7")