-
Notifications
You must be signed in to change notification settings - Fork 0
/
midterm.py
190 lines (169 loc) · 5.07 KB
/
midterm.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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
#Midterm Exam
#Class:- EECS 1015
#Author:- Hoshner Tavadia
#Email:- [email protected]/[email protected]
#Student Id:- 217828
import random
#TASK0 Print Details
def task0():
print("Midterm Exam - EECS1015\nName: Hoshner Tavadia\nStudent ID: 217828567\nEmail: [email protected] / [email protected]\n\n")
#TASK1 Monthly Wage Calculator
def task1():
print("\nKindly Enter The Following Details:")
fname = input("Enter First Name :- ")
fname = fname.title().strip()
lname = input("Enter Last Name :- ")
lname = lname.upper().strip()
hrs = input("Number Of Hours You Work Per Week (Numbers Only):- ")
hrs = float(hrs)
hrwages = input("Enter Hourly Wages (Numbers Only):- ")
hrwages = float(hrwages)
wages = 4*hrs*hrwages
tax = wages*0.25
netwage = wages*0.75
print(f"""Employee = {lname}, {fname}
${wages:.2f} \tMonthly Salary (gross)
-${tax:.2f} \t25% Tax Deduction
=${netwage:.2f} \tMonthly Salary (net)""")
print("\n")
#TASK2 Restaurant Menu
def task2():
print("\nRestaurant Menu")
money = 10.00
def print2(x):
print(f"You Have ${x:.2f} - what item do you want?")
print("1: Falafel\t$3.00")
print("2: Pizza\t$6.00")
print("3: Salad\t$1.50")
print("4: Coffee\t$1.00")
print("Enter 0 to exit")
while money > 0:
print2(money)
order = int(input("Your Order :- "))
if(order==0):
break
elif (order==1):
if(money>=3):
print("Order For *falafel* confirmed.\n")
money = money-3.00
else:
print("Sorry, you don't have enough money for that item.\n")
elif (order == 2):
if (money >= 6):
print("Order For *pizza* confirmed.\n")
money = money - 6.00
else:
print("Sorry, you don't have enough money for that item.\n")
elif (order==3):
if(money>=1.5):
print("Order For *salad* confirmed.\n")
money = money-1.50
else:
print("Sorry, you don't have enough money for that item.\n")
elif (order==4):
if(money>=1):
print("Order For *coffee* confirmed.\n")
money = money-1.00
else:
print("Sorry, you don't have enough money for that item.\n")
else:
print("Invalid menu item. Try Again.\n")
print("Thank You!!")
print("\n")
#TASK3 Dice Roll
def task3():
print("\nDICE ROLL GAME\n")
def game():
six = 0
print("\nGenerating Dice Roll.........")
for x in range(0,10):
y = random.randint(1,6)
if y == 6:
six = six+1
print("*["+str(y)+"]*")
else:
print("["+str(y)+"]")
if(six>1):
print("You Win!!")
else:
print("You Lose :(")
print()
print("Play Again?? (Y/N)")
play = input().upper().strip()
if play =="Y":
game()
else:
print('Thank You For Playing\n')
game()
#TASK4 DNA SEQUENCE
def task4():
def generateDNASequence():
str = ""
for x in range(40):
y = random.randint(1,4)
if (y==1):
str = str+"A"
elif (y==2):
str = str+"C"
elif (y==3):
str =str+"G"
else:
str=str+"T"
return str
def applyGammaRadiation(str):
mutate = random.randint(1,100)
if mutate>50:
ch = 1
str1 = ""
mutatedcharacter = random.randint(0,39)
while ch==1:
y = random.randint(1,4)
if (y == 1):
ch ="A"
elif (y == 2):
ch ="C"
elif (y == 3):
ch ="G"
elif (y==4):
ch ="T"
if (str[mutatedcharacter]==ch):
ch=1
str1=str[0:mutatedcharacter]+ch+str[mutatedcharacter+1:]
return str1
else:
str1 = str
return str1
def detectMutation(x,y): # error showing fix asap
mut = " "*40
mut = mut
for a in range(40):
if (x[a]==y[a]):
pass
else:
mut=mut[0:a]+"^"+mut[a+1:]
return mut
def print_result(orig,mod,loc):
print(orig + "\t(Original DNA)")
print(mod + "\t(DNA After Radiation)")
print(z)
if(orig==mod):
print("NO MUTATION DETECTED")
else:
print("MUTATION DETECTED")
DNA=generateDNASequence()
mutDNA=applyGammaRadiation(DNA)
z=detectMutation(DNA,mutDNA)
print_result(DNA,mutDNA,z)
def main():
task0()
print("\n--TASK 1 --")
task1()
print("\n--Task 2 --")
task2()
print("\n--Task 3 --")
task3()
print("\n--Task 4 --\n")
task4()
input()
if __name__=="__main__":
main()