-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path3_2_Calcolatrice_Funzioni.py
120 lines (79 loc) · 3.23 KB
/
3_2_Calcolatrice_Funzioni.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
import math
def addizione(x, y):
tot = x + y
return(tot)
def sottrazione(x, y):
tot = x - y
return(tot)
def moltiplicazione(x, y):
tot = x * y
return(tot)
def divisione(x, y):
tot = x / y
return(tot)
def potenza(x, y):
tot = x ** y
return(tot)
def radice(x):
tot = math.sqrt(x
)
return(tot)
while True:
print('''
___________________________________________________________________________
|
Programma Calcolatrice in Python |
|
Selezionare l'operazione tra quelle sotto riportate: |
|
- Addizione PREMERE [1] |
- Sottrazione PREMERE [2] |
- Moltiplicazione PREMERE [3] |
- Divisione PREMERE [4] |
- Potenza PREMERE [5] |
- Radice PREMERE [6] |
|
-USCIRE PREMERE [0] |
|
__________________________________________________________________________|
''')
dec = int(input('Quale operazione si desidera effettuare: '))
tot = 0
if dec == 1:
print("Hai scelto: ADDIZIONE\n")
x = int(input("Primo valore: "))
y = int(input("Secondo valore: "))
tot = addizione(x, y)
elif dec == 2:
print("Hai scelto: SOTTRAZIONE\n")
x = int(input("Primo valore: "))
y = int(input("Secondo valore: "))
tot = sottrazione(x, y)
elif dec == 3:
print("Hai scelto: MOLTIPLICAZIONE\n")
x = int(input("Primo valore: "))
y = int(input("Secondo valore: "))
tot = moltiplicazione(x, y)
elif dec == 4:
print("Hai scelto: DIVISIONE\n")
x = int(input("Primo valore: "))
y = int(input("Secondo valore: "))
tot = divisione(x, y)
elif dec == 5:
print("Hai scelto: POTENZA\n")
x = int(input("Base: "))
y = int(input("Esponente: "))
tot = potenza(x, y)
elif dec == 6:
print("Hai scelto: RADICE\n")
x = int(input("Valore: "))
tot = radice(x)
else:
print('''
#######################################################################################
EXIT PROGRAM
#######################################################################################
''')
break
print("\nIl risultato è: " + str(tot))
input("\n\nPREMERE UN QUALSIASI TASTO PER CONTINUARE")