-
Notifications
You must be signed in to change notification settings - Fork 1
/
6.Project Windows.py
206 lines (200 loc) · 6.81 KB
/
6.Project Windows.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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
'''
Title: Best Quadratic Problem
Authors: Riley Carpenter, Liam Kiely, Bosah Mbajekwe
TODO: Find an online compiler, make it funnier
'''
#This is the area where we do our Psuedocode
'''
a is first input
if a is 0
output an error
if a is not 0
b is second input
c is third input
set discriminate as (b ^ 2) - ((4 * a * c))
output discriminate
if discriminate is less than 0
output that it has complex roots
if d is greater than 0
set rootofd as squareroot of discriminate
set firstanswer as (-b) + rootofd
set secondanswer as (-b) - rootofd
set firstanswer as firstanswer / (2 * a)
set secondanswer as secondanswer / (2 * a)
set every variable we've done to strings
output "There are two roots"
output "The roots of",a + "x² + ",b + "x + ",c,"are",firstanswer,secondanswer
otherwise
output "There is one repeated root"
'''
import cmath
import math
import time
import sys
import os
import decimal
decimal.getcontext().prec=8
import winsound
print("Is this being run on replit?")
replit = input("Is this running on Repl.it? (Acceptable answers are yes or no) ")
if replit == "yes":
print("DISCLAIMER: Running this on repl.it will cause some things (screen clearing and background music) to not happen. If you would like to run this on your desktop go here https://bit.ly/2HCskUu")
if replit == "yes":
time.sleep(5)
if sys.platform == "linux" or sys.platform == "posix":
clearorcls = "clear"
else:
clearorcls = "cls"
def stopsound():
if replit == "no":
winsound.PlaySound(None, winsound.SND_ASYNC)
def playsound(musicfile):
winsound.PlaySound(musicfile, winsound.SND_ASYNC)
def title():
print("""
/==================================================\
| ____ __ __ _ |
| / __ \__ ______ _____/ /________ _/ /_(_)____ |
| / / / / / / / __ `/ __ / ___/ __ `/ __/ / ___/ |
| / /_/ / /_/ / /_/ / /_/ / / / /_/ / /_/ / /__ |
| \___\_\__,_/\__,_/\__,_/_/ \__,_/\__/_/\___/ |
| |
\==================================================/
""")
def manyspace():
if replit == "no":
os.system(clearorcls)
else:
print("""
""")
def intro():
title()
playedbefore = "no"
playsound("Main-Menu.wav")
print("""
What would you like to do?
1. Roots
2. Credits
3. About
4. Exit
""")
introchoice = input("What do you want to do? ")
if introchoice == "credits" or introchoice == "Credits" or introchoice == '2':
credits()
elif introchoice == "exit" or introchoice == "Exit" or introchoice == '4':
exit()
elif introchoice == "about" or introchoice == "About" or introchoice == "3":
about()
else:
if playedbefore == "no":
playsound("Song003.wav")
playedbefore = "yes"
program()
def about():
playsound("Aboutmusic.wav")
manyspace()
print("This program will find the real roots of a quadratic equation of the form ax^2 + bx + c = 0, where a, b, and c are real numbers, and a is nonzero. Viva la TOTO")
wait = input("Press any button")
intro()
manyspace()
def restartmaybe():
manyspace()
print("""
What would you like to do?
1. Another equation
2. Go to the home screen
3. Exit.
""")
print("")
restart = input("What do you want to do? ")
if restart == "another equation" or restart == "Another Equation" or restart == "Another Restart" or restart == "another Equation" or restart == "Another" or restart == "another" or restart == "equation" or restart == "Equation" or restart == '1':
manyspace()
program()
elif restart == "Home screen" or restart == "home Screen" or restart == "Home Screen" or restart == "home screen" or restart == "home" or restart == "Home" or restart == "homescreen" or restart == '2':
manyspace()
intro()
else:
manyspace()
exit()
def credits():
if replit == "no":
playsound("song001.wav")
os.system(clearorcls)
print("")
print("Quadratic was made possible by the great members on our team")
print("")
time.sleep(3)
manyspace()
print("Project Leader")
print("Riley Carpenter")
time.sleep(3)
manyspace()
print("Programmer, GUI dev, and head of research development")
print("Bosah Mbajekwe")
time.sleep(3)
manyspace()
print("Second in Command, Playtester, and Graphic Designer")
print("Liam Kiely")
print("")
print("")
time.sleep(3)
print("And viewers like you")
print("")
print("Thank you")
time.sleep(3)
if replit == "no":
stopsound()
manyspace()
intro()
def exit():
playsound("Sound002.wav")
print("Come back anytime!")
time.sleep(4)
os._exit(0)
def program():
manyspace()
a = float(input("Enter any number that is not 0 for a. "))
while a == 0:
print("It has to be a number that isn't 0!")
a = float(input("PLEASE enter any number that is not 0 for a. "))
b = float(input("Enter a real number for B "))
c = float(input("Enter a real number for C "))
discriminate = (b ** 2) - (4 * a * c)
print("The descriminate of this equation is",discriminate)
if discriminate < 0:
print("This has complex roots")
rootofdiscriminate = cmath.sqrt(discriminate)
firstanswer = (-1 * b) + rootofdiscriminate
secondanswer = (-1 * b) - rootofdiscriminate
firstanswer /= (2 * a)
secondanswer /= (2 * a)
a = str(a)
b = str(b)
c = str(c)
firstanswer = str("{0:.6f}".format(firstanswer))
secondanswer = str("{0:.6f}".format(secondanswer))
firstanswer = firstanswer.replace("j","i")
secondanswer = secondanswer.replace("j","i")
print("The roots of",a +"x² +",b +"x +",c,"are",firstanswer,"and",secondanswer)
elif discriminate == 0:
print("There is only one repeated root")
else:
rootofdiscriminate = math.sqrt(discriminate)
firstanswer = (-1 * b) + rootofdiscriminate
secondanswer = (-1 * b) - rootofdiscriminate
firstanswer /= (2 * a)
secondanswer /= (2 * a)
a = str(a)
b = str(b)
c = str(c)
firstanswer = str(float("{0:.6f}".format(firstanswer)))
secondanswer = str(float("{0:.6f}".format(secondanswer)))
print("This has two real roots")
print("The roots of",a +"x² +",b +"x +",c,"are",firstanswer,"and",secondanswer)
wait = input("Press enter when you have finished reviewing the answer")
restartmaybe()
if replit == "no":
playsound("soundthatneedstoplayatthebeginningforaveryspecificreasonthatidontknow-49490711.wav")
manyspace()
intro()
#