-
Notifications
You must be signed in to change notification settings - Fork 0
/
Calculator.py
79 lines (70 loc) · 2.73 KB
/
Calculator.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
# Simple Calculator Program made by Owen Conrad 9/6/2022
from scipy.stats import binom
from cmath import sqrt
# Define our addition operand
def Add_Calc():
a = float(input("Please input a value for the 1st number: "))
b = float(input("Please input a value for the 2nd number: "))
operand = a + b
print(a, '+', b, '=', operand)
# Define our subtraction operand
def Minus_Calc():
a = float(input("Please input a value for the 1st number: "))
b = float(input("Please input a value for the 2nd number: "))
operand = a - b
print(a, '-', b, '=', operand)
# Define our subtraction operand
def Product_Calc():
a = float(input("Please input a value for the 1st number: "))
b = float(input("Please input a value for the 2nd number: "))
operand = a * b
print(a, '*', b, '=', operand)
# Define our subtraction operand
def Quotient_Calc():
a = float(input("Please input a value for the 1st number: "))
b = float(input("Please input a value for the 2nd number: "))
operand = a / b
print(a, '/', b, '=', operand)
def Quadratic_calc():
print('\nHere is the base equation: Ax^2 + Bx + C')
a = float(input("Please input a value for A: "))
b = float(input("Please input a value for B: "))
c = float(input("Please input a value for C: "))
operand1 = ((-b + sqrt(b ** 2 - 4 * a * c)) / (2 * a))
operand2 = ((-b - sqrt(b ** 2 - 4 * a * c)) / (2 * a))
print('\nYour roots are', operand1, 'and', operand2)
# Define our Binomial Distribution operand
def Binomial_Calc():
n = float(input("Please input a value for the number of trials: "))
k = float(input("Please input a value for the number of successes desired: "))
p = float(input("Please input a value for the probability of getting a success in one trial: "))
operand = binom.pmf(n=n, k=k, p=p)
print("The probability of", k, 'successes in', n, 'trials is', operand)
# Define our calculator
def Calculator():
if Selection == 1:
Add_Calc()
elif Selection == 2:
Minus_Calc()
elif Selection == 3:
Product_Calc()
elif Selection == 4:
Quotient_Calc()
elif Selection == 5:
Quadratic_calc()
elif Selection == 6:
Binomial_Calc()
while True:
print('\nHello this is the calculator app')
print('1 = Addition')
print('2 = Subtraction')
print('3 = Multiplication')
print('4 = Division')
print('5 = Quadratic Formula')
print('6 = Binomial Distribution')
Selection = float(input('\nPlease select from the operations above: '))
Calculator()
next_calc = input('\nWould you like to do another calculation? ')
if next_calc == 'no' or next_calc == 'n':
print('\nThank you for using the calculator app. Have a great day!')
break