feat: Initial commit
This commit is contained in:
11
Laboratorio6/countWords.py
Normal file
11
Laboratorio6/countWords.py
Normal file
@@ -0,0 +1,11 @@
|
||||
def countWords(stt):
|
||||
sta = stt.split()
|
||||
return len(sta)
|
||||
|
||||
|
||||
def main():
|
||||
uinput = input("Inserisci una frase: ")
|
||||
print("Il numero di parole è", countWords(uinput))
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
29
Laboratorio6/esercizioReddito.py
Normal file
29
Laboratorio6/esercizioReddito.py
Normal file
@@ -0,0 +1,29 @@
|
||||
def sussidio(reddito, figli):
|
||||
if 30000 < reddito <= 40000 and figli >= 3:
|
||||
return figli * 1000
|
||||
|
||||
if 20000 < reddito <= 30000 and figli >= 2:
|
||||
return figli * 1500
|
||||
|
||||
if reddito <= 20000 and figli >= 1:
|
||||
return figli * 2000
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
def main():
|
||||
print("Inserisci -1 per interrompere il programma")
|
||||
while True:
|
||||
reddito = int(input("Inserisci il reddito: "))
|
||||
figli = int(input("Inserisci il numero di figli: "))
|
||||
|
||||
if reddito == -1 or figli == -1:
|
||||
break
|
||||
|
||||
print("Il sussidio è", sussidio(reddito, figli))
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
|
||||
|
||||
46
Laboratorio6/romaniToArabi.py
Normal file
46
Laboratorio6/romaniToArabi.py
Normal file
@@ -0,0 +1,46 @@
|
||||
def valoreSingolo(cifra):
|
||||
if cifra == "I":
|
||||
return 1
|
||||
|
||||
if cifra == "V":
|
||||
return 5
|
||||
|
||||
if cifra == "X":
|
||||
return 10
|
||||
|
||||
if cifra == "L":
|
||||
return 50
|
||||
|
||||
if cifra == "C":
|
||||
return 100
|
||||
|
||||
if cifra == "D":
|
||||
return 500
|
||||
|
||||
if cifra == "M":
|
||||
return 1000
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
def romaniToArabi(romano):
|
||||
rlist = list(romano)
|
||||
|
||||
totale = 0
|
||||
while len(rlist) > 0:
|
||||
if len(rlist) == 1 or valoreSingolo(rlist[0]) >= valoreSingolo(rlist[1]):
|
||||
totale += valoreSingolo(rlist[0])
|
||||
rlist.pop(0)
|
||||
else:
|
||||
totale += valoreSingolo(rlist[1]) - valoreSingolo(rlist[0])
|
||||
rlist.pop(0)
|
||||
rlist.pop(0)
|
||||
|
||||
return totale
|
||||
|
||||
def main():
|
||||
uinput = input("Inserisci un numero romano: ")
|
||||
print("L'equivalente in numeri arabi è", romaniToArabi(uinput))
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
7
Laboratorio6/saldoBancario.py
Normal file
7
Laboratorio6/saldoBancario.py
Normal file
@@ -0,0 +1,7 @@
|
||||
def calcolaSaldo(saldo, tasso, anni):
|
||||
for _ in range(anni):
|
||||
saldo *= (1 + tasso)
|
||||
|
||||
return saldo
|
||||
|
||||
print(calcolaSaldo(10000, 0.01, 10))
|
||||
14
Laboratorio6/vocali.py
Normal file
14
Laboratorio6/vocali.py
Normal file
@@ -0,0 +1,14 @@
|
||||
def countVowel(str):
|
||||
c = 0
|
||||
for ch in str:
|
||||
if ch.lower() in "aeiou":
|
||||
c += 1
|
||||
|
||||
return c
|
||||
|
||||
def main():
|
||||
uinput = input("Inserisci una frase: ")
|
||||
print("Il numero di vocali è", countVowel(uinput))
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user