feat: Initial commit
This commit is contained in:
6
Laboratorio3/bisestile.py
Normal file
6
Laboratorio3/bisestile.py
Normal file
@@ -0,0 +1,6 @@
|
||||
anno = int(input("Inserisci un anno: "))
|
||||
|
||||
if anno % 400 == 0 or (anno % 4 == 0 and anno % 100 != 0):
|
||||
print("L'anno è bisestile")
|
||||
else:
|
||||
print("L'anno non è bisestile")
|
||||
20
Laboratorio3/checkString.py
Normal file
20
Laboratorio3/checkString.py
Normal file
@@ -0,0 +1,20 @@
|
||||
sus = input("Inserisci una stringa: ")
|
||||
|
||||
if sus.isalpha():
|
||||
if sus.isupper():
|
||||
print("La stringa contiene soltanto lettere maiuscole")
|
||||
elif sus.islower():
|
||||
print("La stringa contiene soltanto lettere minuscole")
|
||||
else:
|
||||
print("La stringa contiene soltanto lettere")
|
||||
elif sus.isnumeric():
|
||||
print("La stringa contiene soltanto numeri")
|
||||
elif sus.isalnum():
|
||||
print("La stringa contiene soltanto lettere e cifre")
|
||||
|
||||
if len(sus) > 0:
|
||||
if sus[0].isupper():
|
||||
print("La stringa inizia con una maiuscola")
|
||||
|
||||
if sus[-1] == ".":
|
||||
print("La stringa finisce con un punto")
|
||||
45
Laboratorio3/convert.py
Normal file
45
Laboratorio3/convert.py
Normal file
@@ -0,0 +1,45 @@
|
||||
from sys import exit
|
||||
|
||||
fr = input("Convert from? ")
|
||||
to = input("Convert to? ")
|
||||
|
||||
factor = 0
|
||||
|
||||
if fr == "ml" or fr == "l":
|
||||
if to == "fl. oz":
|
||||
factor = 0.033814
|
||||
elif to == "gal":
|
||||
factor = 0.000264172
|
||||
|
||||
if fr == "l":
|
||||
factor *= 1000
|
||||
|
||||
if fr == "g" or fr == "kg":
|
||||
if to == "oz":
|
||||
factor = 0.035274
|
||||
elif to == "lb":
|
||||
factor = 0.00220462
|
||||
|
||||
if fr == "kg":
|
||||
factor *= 1000
|
||||
|
||||
if fr == "mm" or fr == "cm" or fr == "m" or fr == "km":
|
||||
if to == "ft":
|
||||
factor = 0.00328084
|
||||
elif to == "mi":
|
||||
factor = 6.21371 * 10**(-7)
|
||||
|
||||
if fr == "cm":
|
||||
factor *= 10
|
||||
elif fr == "m":
|
||||
factor *= 1000
|
||||
elif fr == "km":
|
||||
factor *= 1000000
|
||||
|
||||
if factor == 0:
|
||||
exit("Impossible conversion")
|
||||
|
||||
val1 = float(input("Value? "))
|
||||
val2 = val1 * factor
|
||||
|
||||
print(val1, " ", fr, " = ", val2, " ", to)
|
||||
27
Laboratorio3/seasons.py
Normal file
27
Laboratorio3/seasons.py
Normal file
@@ -0,0 +1,27 @@
|
||||
from sys import exit
|
||||
|
||||
month = int(input("Inserisci il mese: "))
|
||||
day = int(input("Inserisci il giorno: "))
|
||||
|
||||
if 1 <= month <= 3:
|
||||
mw = "Winter"
|
||||
elif 4 <= month <= 6:
|
||||
mw = "Spring"
|
||||
elif 7 <= month <= 9:
|
||||
mw = "Summer"
|
||||
elif 10 <= month <= 12:
|
||||
mw = "Fall"
|
||||
else:
|
||||
exit("Invalid month")
|
||||
|
||||
if month % 3 == 0 and day >= 21:
|
||||
if mw == "Winter":
|
||||
mw = "Spring"
|
||||
elif mw == "Spring":
|
||||
mw = "Summer"
|
||||
elif mw == "Summer":
|
||||
mw = "Fall"
|
||||
elif mw == "Fall":
|
||||
mw = "Winter"
|
||||
|
||||
print("La stagione è ", mw)
|
||||
19
Laboratorio3/tasse.py
Normal file
19
Laboratorio3/tasse.py
Normal file
@@ -0,0 +1,19 @@
|
||||
coniugato = input("Sei coniugato (s/n)?") == "s"
|
||||
redditoImponibile = int(input("Inserisci il tuo reddito imponibile"))
|
||||
|
||||
if coniugato:
|
||||
if 0 <= redditoImponibile <= 8000:
|
||||
tasse = redditoImponibile * 0.1
|
||||
elif redditoImponibile <= 32000:
|
||||
tasse = 800 + (redditoImponibile-8000) * 0.15
|
||||
else:
|
||||
tasse = 4400 + (redditoImponibile-32000) * 0.25
|
||||
else:
|
||||
if 0 <= redditoImponibile <= 16000:
|
||||
tasse = redditoImponibile * 0.1
|
||||
elif redditoImponibile <= 64000:
|
||||
tasse = 1600 + (redditoImponibile-16000) * 0.15
|
||||
else:
|
||||
tasse = 8800 + (redditoImponibile-64000) * 0.25
|
||||
|
||||
print("Le tasse sono pari a ", tasse)
|
||||
10
Laboratorio3/trenumeri.py
Normal file
10
Laboratorio3/trenumeri.py
Normal file
@@ -0,0 +1,10 @@
|
||||
a = int(input("Inserisci il primo numero: "))
|
||||
b = int(input("Inserisci il secondo numero: "))
|
||||
c = int(input("Inserisci il terzo numero: "))
|
||||
|
||||
if a < b < c:
|
||||
print("Increasing")
|
||||
elif a > b > c:
|
||||
print("Decreasing")
|
||||
else:
|
||||
print("Neither")
|
||||
29
Laboratorio3/voto.py
Normal file
29
Laboratorio3/voto.py
Normal file
@@ -0,0 +1,29 @@
|
||||
from sys import exit
|
||||
|
||||
letterGrade = input("Inserisci il voto in lettere: ")
|
||||
letter = letterGrade[0]
|
||||
|
||||
if letter == "A":
|
||||
numericGrade = 4
|
||||
elif letter == "B":
|
||||
numericGrade = 3
|
||||
elif letter == "C":
|
||||
numericGrade = 2
|
||||
elif letter == "D":
|
||||
numericGrade = 1
|
||||
elif letter == "F":
|
||||
numericGrade = 0
|
||||
else:
|
||||
exit("Invalid grade")
|
||||
|
||||
if len(letterGrade) > 1:
|
||||
modifier = letterGrade[1]
|
||||
|
||||
if modifier == "+" and numericGrade != 4 and numericGrade != 0:
|
||||
numericGrade += 0.3
|
||||
elif modifier == "-" and numericGrade != 0:
|
||||
numericGrade -= 0.3
|
||||
else:
|
||||
exit("Invalid grade")
|
||||
|
||||
print("Il voto numerico è ", numericGrade)
|
||||
2
Laboratorio3/voto2.py
Normal file
2
Laboratorio3/voto2.py
Normal file
@@ -0,0 +1,2 @@
|
||||
voton = float(input("Inserisci il voto numerico: "))
|
||||
|
||||
Reference in New Issue
Block a user