forked from geekcomputers/Python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
equations.py
49 lines (34 loc) · 1.14 KB
/
equations.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
###
#####
####### by @JymPatel
#####
###
###
##### edited by ... (editors can put their name and thanks for suggestion) :)
###
# what we are going to do
print("We can solve the below equations")
print("1 Quadratic Equation")
# ask what they want to solve
sinput = input("What you would like to solve?")
# for Qdc Eqn
if sinput == "1":
print("We will solve for equation 'a(x^2) + b(x) + c'")
# value of a
a = int(input("What is value of a?"))
b = int(input("What is value of b?"))
c = int(input("What is value of c?"))
D = b ** 2 - 4 * a * c
if D < 0:
print("No real values of x satisfies your equation.")
else:
x1 = (-b + D) / (2 * a)
x2 = (-b - D) / (2 * a)
print("Roots for your equation are", x1, "&", x2)
else:
print("You have selected wrong option.")
print("Select integer for your equation and run this code again")
# end of code
print("You can visit https://github.com/JymPatel/Python3-FirstEdition")
# get NEW versions of equations.py at https://github.com/JymPatel/Python3-FirstEdition with more equations
# EVEN YOU CAN CONTRIBUTE THEIR. EVERYONE IS WELCOMED THERE..