feat: Initial commit
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -158,5 +158,5 @@ cython_debug/
|
|||||||
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
||||||
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
||||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||||
#.idea/
|
.idea/
|
||||||
|
|
||||||
|
|||||||
11
Cicli/interesseComposto.py
Normal file
11
Cicli/interesseComposto.py
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
anno=0
|
||||||
|
somma=float(input("Inserisci il saldo iniziale: "))
|
||||||
|
tasso=float(input("Inserisci il tasso di interesse: "))
|
||||||
|
|
||||||
|
saldo = somma
|
||||||
|
|
||||||
|
while saldo < 2*somma:
|
||||||
|
anno += 1
|
||||||
|
saldo *= (1+tasso)
|
||||||
|
|
||||||
|
print("Il tuo capitale raddoppierà in ", anno, " anni")
|
||||||
16
Cicli/media.py
Normal file
16
Cicli/media.py
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
somma = 0
|
||||||
|
conto = 0
|
||||||
|
|
||||||
|
while True:
|
||||||
|
uinput = float(input("Voto da inserire: "))
|
||||||
|
|
||||||
|
if uinput == -1:
|
||||||
|
break
|
||||||
|
|
||||||
|
if uinput <= 20:
|
||||||
|
somma += uinput
|
||||||
|
conto += 1
|
||||||
|
|
||||||
|
|
||||||
|
if conto != 0:
|
||||||
|
print("La media è: ", somma/conto)
|
||||||
102
EsRiassuntivi/magazzino/magazzino.py
Normal file
102
EsRiassuntivi/magazzino/magazzino.py
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
from typing import cast
|
||||||
|
|
||||||
|
|
||||||
|
def loadFile(filename: str):
|
||||||
|
in_file = open(filename, "r")
|
||||||
|
items = {}
|
||||||
|
|
||||||
|
for item in in_file:
|
||||||
|
ispl = item.split()
|
||||||
|
iname = ispl[0].strip()
|
||||||
|
cost = float(ispl[1])
|
||||||
|
count = int(ispl[2])
|
||||||
|
|
||||||
|
items[iname] = [cost, count]
|
||||||
|
|
||||||
|
in_file.close()
|
||||||
|
return items
|
||||||
|
|
||||||
|
|
||||||
|
def saveFile(filename: str, items: dict):
|
||||||
|
out_file = open(filename, "w")
|
||||||
|
|
||||||
|
for key in items:
|
||||||
|
out_file.write(key + "\t" + str(items[key][0]) + "\t" + str(items[key][1]) + "\n")
|
||||||
|
|
||||||
|
out_file.close()
|
||||||
|
|
||||||
|
|
||||||
|
def handleCommand(items: dict):
|
||||||
|
command = input("Inserisci un comando: ")
|
||||||
|
|
||||||
|
if command == "XXXXXX":
|
||||||
|
return False
|
||||||
|
|
||||||
|
command = command.split()
|
||||||
|
|
||||||
|
if len(command) != 2:
|
||||||
|
print("Comando non valido!")
|
||||||
|
return True
|
||||||
|
|
||||||
|
key = command[0]
|
||||||
|
op = command[1][0]
|
||||||
|
|
||||||
|
try:
|
||||||
|
delta = int(command[1][1:])
|
||||||
|
except ValueError:
|
||||||
|
print("Valore numerico non valido")
|
||||||
|
return True
|
||||||
|
|
||||||
|
if key not in items:
|
||||||
|
print("Il prodotto non è presente nel database!")
|
||||||
|
return True
|
||||||
|
|
||||||
|
if op != "+" and op != "-":
|
||||||
|
print("Operazione non valida")
|
||||||
|
return True
|
||||||
|
|
||||||
|
oldVal = items[key][1]
|
||||||
|
|
||||||
|
if op == "+":
|
||||||
|
newVal = oldVal + delta
|
||||||
|
if newVal > 10000:
|
||||||
|
print("Quantità di prodotto superiore al valore massimo")
|
||||||
|
return True
|
||||||
|
|
||||||
|
items[key][1] = newVal
|
||||||
|
print("Incrementa la quantità di prodotto", key, "di", delta)
|
||||||
|
else:
|
||||||
|
newVal = oldVal - delta
|
||||||
|
if newVal < 0:
|
||||||
|
print("Quantità di prodotto non disponibile")
|
||||||
|
return True
|
||||||
|
|
||||||
|
items[key][1] = newVal
|
||||||
|
print("Decrementa la quantità di prodotto", key, "di", delta)
|
||||||
|
|
||||||
|
print("Valore complessivo precedente:", oldVal)
|
||||||
|
print("Valore complessivo attuale", newVal)
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
in_file_name = input("Inserisci il nome del vecchio file: ")
|
||||||
|
try:
|
||||||
|
items = loadFile(in_file_name)
|
||||||
|
except FileNotFoundError:
|
||||||
|
exit("Errore! File di input non trovato")
|
||||||
|
except:
|
||||||
|
exit("File di input malformato!")
|
||||||
|
|
||||||
|
while handleCommand(items):
|
||||||
|
pass
|
||||||
|
|
||||||
|
out_file_name = input("Inserisci il nome del nuovo file: ")
|
||||||
|
|
||||||
|
try:
|
||||||
|
saveFile(out_file_name, items)
|
||||||
|
except FileNotFoundError:
|
||||||
|
exit("Errore! File di output non trovato")
|
||||||
|
|
||||||
|
main()
|
||||||
5
EsRiassuntivi/magazzino/nuovo.txt
Normal file
5
EsRiassuntivi/magazzino/nuovo.txt
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
ABCD306AZN 20.0 80
|
||||||
|
AZBF39829B 2.0 1000
|
||||||
|
AB302EFA 5.0 400
|
||||||
|
DSKJH34998 0.01 4000
|
||||||
|
FER3942DDDF 0.5 1000
|
||||||
5
EsRiassuntivi/magazzino/vecchio.txt
Normal file
5
EsRiassuntivi/magazzino/vecchio.txt
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
ABCD306AZN 20.00 80
|
||||||
|
AZBF39829B 2.00 1200
|
||||||
|
AB302EFA 5.00 400
|
||||||
|
DSKJH34998 0.01 4000
|
||||||
|
FER3942DDDF 0.5 1000
|
||||||
1
EsRiassuntivi/morse/codice.txt
Normal file
1
EsRiassuntivi/morse/codice.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
... .. ... .- .-.. ...- .. -.-. .... .. .--. ..- --- -.--.-
|
||||||
37
EsRiassuntivi/morse/morse.py
Normal file
37
EsRiassuntivi/morse/morse.py
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
def loadMorse(filename: str, to_ascii: bool):
|
||||||
|
fio = open(filename, "r")
|
||||||
|
|
||||||
|
conv_table = {}
|
||||||
|
|
||||||
|
for line in fio:
|
||||||
|
line = line.split()
|
||||||
|
|
||||||
|
if to_ascii:
|
||||||
|
conv_table[line[1].upper()] = line[0]
|
||||||
|
else:
|
||||||
|
conv_table[line[0]] = line[1].upper()
|
||||||
|
|
||||||
|
conv_table[" "] = " "
|
||||||
|
|
||||||
|
return conv_table
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
to_ascii = input("Vuoi decodificare un file? ") == "si"
|
||||||
|
in_file = input("Inserisci il nome del file: ")
|
||||||
|
|
||||||
|
conv_table = loadMorse("morse.txt", to_ascii)
|
||||||
|
|
||||||
|
with open(in_file, "r") as fio:
|
||||||
|
in_str = fio.readline()
|
||||||
|
|
||||||
|
if to_ascii:
|
||||||
|
for char in in_str.split():
|
||||||
|
print(conv_table[char], end="")
|
||||||
|
else:
|
||||||
|
in_str = list(in_str.upper())
|
||||||
|
for char in in_str:
|
||||||
|
print(conv_table[char], end=" ")
|
||||||
|
|
||||||
|
|
||||||
|
main()
|
||||||
44
EsRiassuntivi/morse/morse.txt
Normal file
44
EsRiassuntivi/morse/morse.txt
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
A .-
|
||||||
|
B -...
|
||||||
|
C -.-.
|
||||||
|
D -..
|
||||||
|
E .
|
||||||
|
F ..-.
|
||||||
|
G --.
|
||||||
|
H ....
|
||||||
|
I ..
|
||||||
|
J .---
|
||||||
|
K -.-
|
||||||
|
L .-..
|
||||||
|
M --
|
||||||
|
N -.
|
||||||
|
O ---
|
||||||
|
P .--.
|
||||||
|
Q --.-
|
||||||
|
R .-.
|
||||||
|
S ...
|
||||||
|
T -
|
||||||
|
U ..-
|
||||||
|
V ...-
|
||||||
|
W .--
|
||||||
|
X -..-
|
||||||
|
Y -.--
|
||||||
|
Z --..
|
||||||
|
, --..--
|
||||||
|
: ---...
|
||||||
|
; -.-.-.
|
||||||
|
. .-.-.-
|
||||||
|
" .-..-.
|
||||||
|
( -----.
|
||||||
|
) .-----
|
||||||
|
' -.--.-
|
||||||
|
1 .----
|
||||||
|
2 ..---
|
||||||
|
3 ...--
|
||||||
|
4 ....-
|
||||||
|
5 .....
|
||||||
|
6 -....
|
||||||
|
7 --...
|
||||||
|
8 ---..
|
||||||
|
9 ----.
|
||||||
|
0 -----
|
||||||
1
EsRiassuntivi/morse/testo.txt
Normal file
1
EsRiassuntivi/morse/testo.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
Si salvi chi puo' forza e coraggio
|
||||||
9631
EsRiassuntivi/qualità_della_vita/20201214_QDV2020_001.csv
Normal file
9631
EsRiassuntivi/qualità_della_vita/20201214_QDV2020_001.csv
Normal file
File diff suppressed because it is too large
Load Diff
35
EsRiassuntivi/qualità_della_vita/qdv.py
Normal file
35
EsRiassuntivi/qualità_della_vita/qdv.py
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
import csv
|
||||||
|
|
||||||
|
with open("20201214_QDV2020_001.csv") as csv_file:
|
||||||
|
csv_reader = csv.reader(csv_file)
|
||||||
|
|
||||||
|
line_count = 0
|
||||||
|
|
||||||
|
rows = []
|
||||||
|
indc = set()
|
||||||
|
|
||||||
|
for row in csv_reader:
|
||||||
|
if line_count == 0:
|
||||||
|
print(f'Column names are {", ".join(row)}')
|
||||||
|
line_count += 1
|
||||||
|
else:
|
||||||
|
row_a = {"provincia": row[0], "valore": row[4], "indicatore": row[5]}
|
||||||
|
indc.add(row[5])
|
||||||
|
rows.append(row_a)
|
||||||
|
|
||||||
|
indc = list(indc)
|
||||||
|
print("Indicatori della qualità della vita:")
|
||||||
|
for i in range(len(indc)):
|
||||||
|
print(str(i+1) + ".", indc[i])
|
||||||
|
|
||||||
|
while True:
|
||||||
|
indic = input("Inserisci l'indicatore: ")
|
||||||
|
|
||||||
|
if indic == "quit":
|
||||||
|
break
|
||||||
|
|
||||||
|
indic = indc[int(indic)]
|
||||||
|
|
||||||
|
rows_filtered = {}
|
||||||
|
for r in rows:
|
||||||
|
if r["indicatore"] == indic
|
||||||
3
Laboratorio10/aaa.txt
Normal file
3
Laboratorio10/aaa.txt
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
lord of the strings
|
||||||
|
sas
|
||||||
|
ring 0
|
||||||
14
Laboratorio10/enumerateLines.py
Normal file
14
Laboratorio10/enumerateLines.py
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
from os import close
|
||||||
|
|
||||||
|
|
||||||
|
fin = open("input.txt", "r")
|
||||||
|
fout = open("output.txt", "w")
|
||||||
|
|
||||||
|
c = 1
|
||||||
|
|
||||||
|
for l in fin:
|
||||||
|
fout.write("/*"+str(c)+"*/"+l)
|
||||||
|
c += 1
|
||||||
|
|
||||||
|
fin.close()
|
||||||
|
fout.close()
|
||||||
31
Laboratorio10/find.py
Normal file
31
Laboratorio10/find.py
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
class color:
|
||||||
|
PURPLE = '\033[95m'
|
||||||
|
CYAN = '\033[96m'
|
||||||
|
DARKCYAN = '\033[36m'
|
||||||
|
BLUE = '\033[94m'
|
||||||
|
GREEN = '\033[92m'
|
||||||
|
YELLOW = '\033[93m'
|
||||||
|
RED = '\033[91m'
|
||||||
|
BOLD = '\033[1m'
|
||||||
|
UNDERLINE = '\033[4m'
|
||||||
|
END = '\033[0m'
|
||||||
|
|
||||||
|
def main():
|
||||||
|
files = input("Insert filenames separated by whitespaces: ").strip().split()
|
||||||
|
|
||||||
|
keyword = input("Insert keyword: ")
|
||||||
|
|
||||||
|
for file in files:
|
||||||
|
try:
|
||||||
|
fio = open(file, "r")
|
||||||
|
except FileNotFoundError:
|
||||||
|
print("File", file, "not found")
|
||||||
|
continue
|
||||||
|
|
||||||
|
for line in fio:
|
||||||
|
if keyword in line.lower():
|
||||||
|
print(file + ":", line.removesuffix("\n").replace(keyword, color.GREEN + color.BOLD + keyword + color.END))
|
||||||
|
|
||||||
|
fio.close()
|
||||||
|
|
||||||
|
main()
|
||||||
5
Laboratorio10/input.txt
Normal file
5
Laboratorio10/input.txt
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
Enola Gay
|
||||||
|
è il bombardiere che il 6 agosto 1945,
|
||||||
|
sganciò su Hiroshima la prima bomba atomica
|
||||||
|
soprannominata Little Boy.
|
||||||
|
rings of the rings
|
||||||
14
Laboratorio10/invertLines.py
Normal file
14
Laboratorio10/invertLines.py
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
from os import close
|
||||||
|
|
||||||
|
|
||||||
|
fin = open("input.txt", "r")
|
||||||
|
fout = open("output.txt", "w")
|
||||||
|
|
||||||
|
lines = reversed(fin.readlines())
|
||||||
|
|
||||||
|
fin.close()
|
||||||
|
|
||||||
|
for l in lines:
|
||||||
|
fout.write(l.strip() + "\n")
|
||||||
|
|
||||||
|
fout.close()
|
||||||
4
Laboratorio10/output.txt
Normal file
4
Laboratorio10/output.txt
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
soprannominata Little Boy.
|
||||||
|
sganciò su Hiroshima la prima bomba atomica
|
||||||
|
è il bombardiere che il 6 agosto 1945,
|
||||||
|
Enola Gay
|
||||||
30
Laboratorio10/vendite.py
Normal file
30
Laboratorio10/vendite.py
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
from sys import exit
|
||||||
|
|
||||||
|
def main():
|
||||||
|
try:
|
||||||
|
fio = open("vendite.txt", "r")
|
||||||
|
except FileNotFoundError:
|
||||||
|
exit("File not found")
|
||||||
|
|
||||||
|
datas = {}
|
||||||
|
|
||||||
|
for line in fio:
|
||||||
|
data = line.split(";")
|
||||||
|
if len(data) != 4:
|
||||||
|
exit("Invalid line: " + line)
|
||||||
|
|
||||||
|
service = data[1].strip()
|
||||||
|
cost = float(data[2].strip())
|
||||||
|
|
||||||
|
if service not in datas:
|
||||||
|
datas[service] = 0
|
||||||
|
|
||||||
|
datas[service] += cost
|
||||||
|
|
||||||
|
|
||||||
|
for key in datas:
|
||||||
|
print(key + ":", datas[key])
|
||||||
|
|
||||||
|
fio.close()
|
||||||
|
|
||||||
|
main()
|
||||||
4
Laboratorio10/vendite.txt
Normal file
4
Laboratorio10/vendite.txt
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
aaa;cena;22;sus
|
||||||
|
bbb;pranzo;40;assa
|
||||||
|
ccc;hotel;22;sdasd
|
||||||
|
ddd;hotel;66s;sas
|
||||||
3
Laboratorio11/bad_words.txt
Normal file
3
Laboratorio11/bad_words.txt
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
sesso
|
||||||
|
droga
|
||||||
|
C++
|
||||||
27
Laboratorio11/censore.py
Normal file
27
Laboratorio11/censore.py
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
def readBadWords(filename: str):
|
||||||
|
fio = open(filename, "r")
|
||||||
|
bad_words = set()
|
||||||
|
|
||||||
|
for line in fio:
|
||||||
|
bad_words.add(line.strip())
|
||||||
|
|
||||||
|
fio.close()
|
||||||
|
return bad_words
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
bad_words = readBadWords("bad_words.txt")
|
||||||
|
|
||||||
|
fio = open("input.txt", "r")
|
||||||
|
fout = open("output.txt", "w")
|
||||||
|
|
||||||
|
for line in fio:
|
||||||
|
for wrd in bad_words:
|
||||||
|
line = line.replace(wrd, "*"*len(wrd))
|
||||||
|
|
||||||
|
fout.write(line)
|
||||||
|
|
||||||
|
fio.close()
|
||||||
|
fout.close()
|
||||||
|
|
||||||
|
main()
|
||||||
32
Laboratorio11/cmqStrings.py
Normal file
32
Laboratorio11/cmqStrings.py
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
from string import printable
|
||||||
|
|
||||||
|
def main():
|
||||||
|
a = list(input("Prima stringa: "))
|
||||||
|
b = list(input("Seconda stringa: "))
|
||||||
|
|
||||||
|
both = set()
|
||||||
|
ina = set()
|
||||||
|
inb = set()
|
||||||
|
nowhere = set()
|
||||||
|
|
||||||
|
for char in printable:
|
||||||
|
ia = char in a
|
||||||
|
iab = char in b
|
||||||
|
|
||||||
|
if ia and iab:
|
||||||
|
both.add(char)
|
||||||
|
elif ia:
|
||||||
|
ina.add(char)
|
||||||
|
elif iab:
|
||||||
|
inb.add(char)
|
||||||
|
else:
|
||||||
|
nowhere.add(char)
|
||||||
|
|
||||||
|
print(both)
|
||||||
|
print(ina)
|
||||||
|
print(inb)
|
||||||
|
print(nowhere)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
main()
|
||||||
40
Laboratorio11/countWords.py
Normal file
40
Laboratorio11/countWords.py
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
def clean(word: str):
|
||||||
|
a = len(word)
|
||||||
|
|
||||||
|
while True:
|
||||||
|
word = word.strip("()[]{}!?.,<>:;-_`’‘")
|
||||||
|
if a == len(word):
|
||||||
|
break
|
||||||
|
|
||||||
|
a = len(word)
|
||||||
|
|
||||||
|
return word
|
||||||
|
|
||||||
|
def main():
|
||||||
|
filename = input("Inserisci il nome del file: ")
|
||||||
|
fio = open(filename, "r")
|
||||||
|
|
||||||
|
words = {}
|
||||||
|
|
||||||
|
for line in fio:
|
||||||
|
for word in line.split():
|
||||||
|
word = clean(word)
|
||||||
|
if word not in words:
|
||||||
|
words[word] = 1
|
||||||
|
else:
|
||||||
|
words[word] += 1
|
||||||
|
|
||||||
|
fio.close()
|
||||||
|
|
||||||
|
vals = sorted(words.values(), reverse=True)
|
||||||
|
|
||||||
|
for i in range(0, 100):
|
||||||
|
for word in words:
|
||||||
|
if words[word] == vals[i]:
|
||||||
|
print(word, end=" ")
|
||||||
|
words.pop(word)
|
||||||
|
break
|
||||||
|
|
||||||
|
print()
|
||||||
|
|
||||||
|
main()
|
||||||
229
Laboratorio11/export.csv
Normal file
229
Laboratorio11/export.csv
Normal file
@@ -0,0 +1,229 @@
|
|||||||
|
name,slug,value,date_of_information,ranking,region
|
||||||
|
"Liechtenstein","liechtenstein","$139,100","2009 est.","1","Europe"
|
||||||
|
"Monaco","monaco","$115,700","2015 est.","2","Europe"
|
||||||
|
"Luxembourg","luxembourg","$110,300","2020 est.","3","Europe"
|
||||||
|
"Singapore","singapore","$93,400","2020 est.","4","East Asia/Southeast Asia"
|
||||||
|
"Ireland","ireland","$89,700","2020 est.","5","Europe"
|
||||||
|
"Qatar","qatar","$85,300","2020 est.","6","Middle East"
|
||||||
|
"Isle of Man","isle-of-man","$84,600","2014 est.","7","Europe"
|
||||||
|
"Bermuda","bermuda","$81,800","2019 est.","8","North America"
|
||||||
|
"Cayman Islands","cayman-islands","$73,600","2019 est.","9","Central America"
|
||||||
|
"Falkland Islands (Islas Malvinas)","falkland-islands-islas-malvinas","$70,800","2015 est.","10","South America"
|
||||||
|
"Switzerland","switzerland","$68,400","2020 est.","11","Europe"
|
||||||
|
"United Arab Emirates","united-arab-emirates","$67,100","2019 est.","12","Middle East"
|
||||||
|
"Norway","norway","$63,600","2020 est.","13","Europe"
|
||||||
|
"Brunei","brunei","$62,200","2020 est.","14","East Asia/Southeast Asia"
|
||||||
|
"Gibraltar","gibraltar","$61,700","2014 est.","15","Europe"
|
||||||
|
"San Marino","san-marino","$60,800","2019 est.","16","Europe"
|
||||||
|
"United States","united-states","$60,200","2020 est.","17","North America"
|
||||||
|
"Jersey","jersey","$56,600","2016 est.","18","Europe"
|
||||||
|
"Hong Kong","hong-kong","$56,200","2020 est.","19","East Asia/Southeast Asia"
|
||||||
|
"Denmark","denmark","$55,900","2020 est.","20","Europe"
|
||||||
|
"Macau","macau","$54,800","2020 est.","21","East Asia/Southeast Asia"
|
||||||
|
"Netherlands","netherlands","$54,200","2020 est.","22","Europe"
|
||||||
|
"Guernsey","guernsey","$52,500","2014 est.","23","Europe"
|
||||||
|
"Iceland","iceland","$52,300","2020 est.","24","Europe"
|
||||||
|
"Austria","austria","$51,900","2020 est.","25","Europe"
|
||||||
|
"Germany","germany","$50,900","2020 est.","26","Europe"
|
||||||
|
"Sweden","sweden","$50,700","2020 est.","27","Europe"
|
||||||
|
"Andorra","andorra","$49,900","2015 est.","28","Europe"
|
||||||
|
"Kuwait","kuwait","$49,900","2019 est.","29","Middle East"
|
||||||
|
"Australia","australia","$48,700","2020 est.","30","Australia - Oceania"
|
||||||
|
"Belgium","belgium","$48,200","2020 est.","31","Europe"
|
||||||
|
"Finland","finland","$47,300","2020 est.","32","Europe"
|
||||||
|
"Saint Pierre and Miquelon","saint-pierre-and-miquelon-2","$46,200","2006 est.","33","North America"
|
||||||
|
"Canada","canada","$45,900","2020 est.","34","North America"
|
||||||
|
"Saudi Arabia","saudi-arabia","$44,300","2020 est.","35","Middle East"
|
||||||
|
"New Zealand","new-zealand","$42,400","2020 est.","36","Australia - Oceania"
|
||||||
|
"Korea, South","korea-south","$42,300","2020 est.","37","East Asia/Southeast Asia"
|
||||||
|
"France","france","$42,000","2020 est.","38","Europe"
|
||||||
|
"Greenland","greenland","$41,800","2015 est.","39","North America"
|
||||||
|
"United Kingdom","united-kingdom","$41,600","2020 est.","40","Europe"
|
||||||
|
"Japan","japan","$41,400","2019 est.","41","East Asia/Southeast Asia"
|
||||||
|
"Bahrain","bahrain","$40,900","2020 est.","42","Middle East"
|
||||||
|
"Faroe Islands","faroe-islands","$40,000","2014 est.","43","Europe"
|
||||||
|
"Malta","malta","$39,200","2020 est.","44","Europe"
|
||||||
|
"Italy","italy","$39,000","2020 est.","45","Europe"
|
||||||
|
"Czechia","czechia","$38,300","2020 est.","46","Europe"
|
||||||
|
"Israel","israel","$38,300","2020 est.","47","Middle East"
|
||||||
|
"Cyprus","cyprus","$37,700","2020 est.","48","Europe"
|
||||||
|
"Aruba","aruba","$37,500","2017 est.","49","Central America"
|
||||||
|
"Virgin Islands","virgin-islands","$37,000","2016 est.","50","Central America"
|
||||||
|
"Lithuania","lithuania","$36,700","2020 est.","51","Europe"
|
||||||
|
"Slovenia","slovenia","$36,500","2020 est.","52","Europe"
|
||||||
|
"Spain","spain","$36,200","2020 est.","53","Europe"
|
||||||
|
"Estonia","estonia","$35,600","2020 est.","54","Europe"
|
||||||
|
"Guam","guam","$35,600","2016 est.","55","Australia - Oceania"
|
||||||
|
"Sint Maarten","sint-maarten","$35,300","2018 est.","56","Central America"
|
||||||
|
"British Virgin Islands","british-virgin-islands","$34,200","2017 est.","57","Central America"
|
||||||
|
"Montserrat","montserrat","$34,000","2011 est.","58","Central America"
|
||||||
|
"Puerto Rico","puerto-rico","$33,400","2020 est.","59","Central America"
|
||||||
|
"Poland","poland","$32,200","2020 est.","60","Europe"
|
||||||
|
"Portugal","portugal","$32,200","2020 est.","61","Europe"
|
||||||
|
"New Caledonia","new-caledonia","$31,100","2015 est.","62","Australia - Oceania"
|
||||||
|
"Hungary","hungary","$31,000","2020 est.","63","Europe"
|
||||||
|
"Bahamas, The","bahamas-the","$30,800","2020 est.","64","Central America"
|
||||||
|
"Slovakia","slovakia","$30,300","2020 est.","65","Europe"
|
||||||
|
"Latvia","latvia","$29,900","2020 est.","66","Europe"
|
||||||
|
"Romania","romania","$28,800","2020 est.","67","Europe"
|
||||||
|
"Turkey","turkey","$28,400","2020 est.","68","Middle East"
|
||||||
|
"Greece","greece","$27,300","2020 est.","69","Europe"
|
||||||
|
"Oman","oman","$27,300","2019 est.","70","Middle East"
|
||||||
|
"Croatia","croatia","$26,500","2020 est.","71","Europe"
|
||||||
|
"Russia","russia","$26,500","2020 est.","72","Central Asia"
|
||||||
|
"Malaysia","malaysia","$26,400","2020 est.","73","East Asia/Southeast Asia"
|
||||||
|
"Panama","panama","$25,400","2020 est.","74","Central America"
|
||||||
|
"Kazakhstan","kazakhstan","$25,300","2020 est.","75","Central Asia"
|
||||||
|
"Taiwan","taiwan","$24,502","2018 est.","76","East Asia/Southeast Asia"
|
||||||
|
"Curacao","curacao","$24,500","2019 est.","77","Central America"
|
||||||
|
"Northern Mariana Islands","northern-mariana-islands","$24,500","2016 est.","78","Australia - Oceania"
|
||||||
|
"Seychelles","seychelles","$24,400","2020 est.","79","Africa"
|
||||||
|
"Trinidad and Tobago","trinidad-and-tobago","$23,700","2020 est.","80","Central America"
|
||||||
|
"Chile","chile","$23,300","2020 est.","81","South America"
|
||||||
|
"Saint Kitts and Nevis","saint-kitts-and-nevis","$23,300","2020 est.","82","Central America"
|
||||||
|
"Bulgaria","bulgaria","$22,400","2020 est.","83","Europe"
|
||||||
|
"Uruguay","uruguay","$21,600","2020 est.","84","South America"
|
||||||
|
"Turks and Caicos Islands","turks-and-caicos-islands","$21,100","2020 est.","85","Central America"
|
||||||
|
"Argentina","argentina","$19,700","2020 est.","86","South America"
|
||||||
|
"Costa Rica","costa-rica","$19,700","2020 est.","87","Central America"
|
||||||
|
"Mauritius","mauritius","$19,500","2020 est.","88","Africa"
|
||||||
|
"Saint Martin","saint-martin","$19,300","2005 est.","89","Central America"
|
||||||
|
"Belarus","belarus","$19,100","2020 est.","90","Europe"
|
||||||
|
"Guyana","guyana","$18,700","2020 est.","91","South America"
|
||||||
|
"Montenegro","montenegro","$18,300","2020 est.","92","Europe"
|
||||||
|
"Serbia","serbia","$18,200","2020 est.","93","Europe"
|
||||||
|
"Antigua and Barbuda","antigua-and-barbuda","$18,000","2020 est.","94","Central America"
|
||||||
|
"Mexico","mexico","$17,900","2020 est.","95","North America"
|
||||||
|
"Palau","palau","$17,600","2019 est.","96","Australia - Oceania"
|
||||||
|
"Thailand","thailand","$17,300","2020 est.","97","East Asia/Southeast Asia"
|
||||||
|
"Dominican Republic","dominican-republic","$17,000","2020 est.","98","Central America"
|
||||||
|
"Equatorial Guinea","equatorial-guinea","$17,000","2020 est.","99","Africa"
|
||||||
|
"French Polynesia","french-polynesia","$17,000","2015 est.","100","Australia - Oceania"
|
||||||
|
"Cook Islands","cook-islands","$16,700","2016 est.","101","Australia - Oceania"
|
||||||
|
"China","china","$16,400","2020 est.","102","East Asia/Southeast Asia"
|
||||||
|
"Suriname","suriname","$16,100","2020 est.","103","South America"
|
||||||
|
"Botswana","botswana","$16,000","2020 est.","104","Africa"
|
||||||
|
"Turkmenistan","turkmenistan","$15,500","2019 est.","106","Central Asia"
|
||||||
|
"Grenada","grenada","$15,100","2020 est.","107","Central America"
|
||||||
|
"Gabon","gabon","$14,400","2020 est.","108","Africa"
|
||||||
|
"Bosnia and Herzegovina","bosnia-and-herzegovina","$14,300","2020 est.","109","Europe"
|
||||||
|
"Brazil","brazil","$14,100","2020 est.","110","South America"
|
||||||
|
"Georgia","georgia","$14,100","2020 est.","111","Middle East"
|
||||||
|
"Azerbaijan","azerbaijan","$13,700","2020 est.","112","Middle East"
|
||||||
|
"Nauru","nauru","$13,500","2019 est.","113","Australia - Oceania"
|
||||||
|
"Colombia","colombia","$13,400","2020 est.","114","South America"
|
||||||
|
"Albania","albania","$13,300","2020 est.","115","Europe"
|
||||||
|
"Maldives","maldives","$13,000","2020 est.","116","South Asia"
|
||||||
|
"Barbados","barbados","$12,900","2020 est.","117","Central America"
|
||||||
|
"Armenia","armenia","$12,600","2020 est.","118","Middle East"
|
||||||
|
"Sri Lanka","sri-lanka","$12,500","2020 est.","119","South Asia"
|
||||||
|
"Iran","iran","$12,400","2020 est.","120","Middle East"
|
||||||
|
"Ukraine","ukraine","$12,400","2020 est.","121","Europe"
|
||||||
|
"Cuba","cuba","$12,300","2016 est.","122","Central America"
|
||||||
|
"Moldova","moldova","$12,300","2020 est.","123","Europe"
|
||||||
|
"Paraguay","paraguay","$12,300","2020 est.","124","South America"
|
||||||
|
"Saint Lucia","saint-lucia","$12,300","2020 est.","125","Central America"
|
||||||
|
"Anguilla","anguilla","$12,200","2008 est.","126","Central America"
|
||||||
|
"Saint Vincent and the Grenadines","saint-vincent-and-the-grenadines","$12,100","2020 est.","127","Central America"
|
||||||
|
"Egypt","egypt","$12,000","2020 est.","128","Africa"
|
||||||
|
"Lebanon","lebanon","$11,600","2020 est.","129","Middle East"
|
||||||
|
"Mongolia","mongolia","$11,500","2020 est.","130","East Asia/Southeast Asia"
|
||||||
|
"South Africa","south-africa","$11,500","2020 est.","131","Africa"
|
||||||
|
"Indonesia","indonesia","$11,400","2020 est.","132","East Asia/Southeast Asia"
|
||||||
|
"Peru","peru","$11,300","2020 est.","133","South America"
|
||||||
|
"American Samoa","american-samoa","$11,200","2016 est.","134","Australia - Oceania"
|
||||||
|
"Fiji","fiji","$11,000","2020 est.","135","Australia - Oceania"
|
||||||
|
"Bhutan","bhutan","$10,900","2020 est.","136","South Asia"
|
||||||
|
"Kosovo","kosovo","$10,800","2020 est.","137","Europe"
|
||||||
|
"Algeria","algeria","$10,700","2020 est.","138","Africa"
|
||||||
|
"Ecuador","ecuador","$10,300","2020 est.","139","South America"
|
||||||
|
"Libya","libya","$10,300","2020 est.","140","Africa"
|
||||||
|
"Dominica","dominica","$9,900","2020 est.","141","Central America"
|
||||||
|
"Jordan","jordan","$9,800","2020 est.","142","Middle East"
|
||||||
|
"Tunisia","tunisia","$9,700","2020 est.","143","Africa"
|
||||||
|
"Iraq","iraq","$9,300","2020 est.","144","Middle East"
|
||||||
|
"Namibia","namibia","$8,900","2020 est.","145","Africa"
|
||||||
|
"Jamaica","jamaica","$8,700","2020 est.","146","Central America"
|
||||||
|
"Eswatini","eswatini","$8,400","2020 est.","147","Africa"
|
||||||
|
"Guatemala","guatemala","$8,400","2020 est.","148","Central America"
|
||||||
|
"Vietnam","vietnam","$8,200","2020 est.","149","East Asia/Southeast Asia"
|
||||||
|
"El Salvador","el-salvador","$8,100","2020 est.","150","Central America"
|
||||||
|
"Philippines","philippines","$8,000","2020 est.","151","East Asia/Southeast Asia"
|
||||||
|
"Bolivia","bolivia","$7,900","2020 est.","152","South America"
|
||||||
|
"Laos","laos","$7,800","2020 est.","153","East Asia/Southeast Asia"
|
||||||
|
"Saint Helena, Ascension, and Tristan da Cunha","saint-helena-ascension-and-tristan-da-cunha","$7,800","FY09/10 est.","154","Africa"
|
||||||
|
"Venezuela","venezuela","$7,704","2018 est.","155","South America"
|
||||||
|
"Uzbekistan","uzbekistan","$7,000","2020 est.","156","Central Asia"
|
||||||
|
"Morocco","morocco","$6,900","2020 est.","157","Africa"
|
||||||
|
"Tonga","tonga","$6,400","2019 est.","158","Australia - Oceania"
|
||||||
|
"Samoa","samoa","$6,300","2020 est.","159","Australia - Oceania"
|
||||||
|
"Gaza Strip","gaza-strip","$6,220","2019 est.","160","Middle East"
|
||||||
|
"Angola","angola","$6,200","2020 est.","161","Africa"
|
||||||
|
"Belize","belize","$6,100","2020 est.","162","Central America"
|
||||||
|
"India","india","$6,100","2020 est.","163","South Asia"
|
||||||
|
"Tokelau","tokelau","$6,004","2017 est.","164","Australia - Oceania"
|
||||||
|
"Cabo Verde","cabo-verde","$6,000","2020 est.","165","Africa"
|
||||||
|
"Niue","niue","$5,800","2003 est.","166","Australia - Oceania"
|
||||||
|
"Djibouti","djibouti","$5,500","2020 est.","167","Africa"
|
||||||
|
"West Bank","west-bank","$5,400","2020 est.","168","Middle East"
|
||||||
|
"Ghana","ghana","$5,300","2020 est.","169","Africa"
|
||||||
|
"Nicaragua","nicaragua","$5,300","2020 est.","170","Central America"
|
||||||
|
"Cote d'Ivoire","cote-divoire","$5,200","2020 est.","171","Africa"
|
||||||
|
"Honduras","honduras","$5,100","2020 est.","172","Central America"
|
||||||
|
"Mauritania","mauritania","$5,000","2020 est.","173","Africa"
|
||||||
|
"Nigeria","nigeria","$4,900","2020 est.","174","Africa"
|
||||||
|
"Bangladesh","bangladesh","$4,800","2020 est.","175","South Asia"
|
||||||
|
"Kyrgyzstan","kyrgyzstan","$4,700","2020 est.","176","Central Asia"
|
||||||
|
"Pakistan","pakistan","$4,600","2020 est.","177","South Asia"
|
||||||
|
"Burma","burma","$4,500","2020 est.","178","East Asia/Southeast Asia"
|
||||||
|
"Tuvalu","tuvalu","$4,400","2020 est.","179","Australia - Oceania"
|
||||||
|
"Cambodia","cambodia","$4,200","2020 est.","180","East Asia/Southeast Asia"
|
||||||
|
"Kenya","kenya","$4,200","2020 est.","181","Africa"
|
||||||
|
"Papua New Guinea","papua-new-guinea","$4,100","2020 est.","182","East Asia/Southeast Asia"
|
||||||
|
"Sao Tome and Principe","sao-tome-and-principe","$4,100","2020 est.","183","Africa"
|
||||||
|
"Marshall Islands","marshall-islands","$4,000","2019 est.","184","Australia - Oceania"
|
||||||
|
"Sudan","sudan","$4,000","2020 est.","185","Africa"
|
||||||
|
"Nepal","nepal","$3,800","2020 est.","186","South Asia"
|
||||||
|
"Wallis and Futuna","wallis-and-futuna","$3,800","2004 est.","187","Australia - Oceania"
|
||||||
|
"Tajikistan","tajikistan","$3,700","2020 est.","188","Central Asia"
|
||||||
|
"Cameroon","cameroon","$3,600","2020 est.","189","Africa"
|
||||||
|
"Micronesia, Federated States of","micronesia-federated-states-of","$3,500","2019 est.","190","Australia - Oceania"
|
||||||
|
"Congo, Republic of the","congo-republic-of-the","$3,400","2020 est.","191","Africa"
|
||||||
|
"Benin","benin","$3,300","2020 est.","192","Africa"
|
||||||
|
"Senegal","senegal","$3,300","2020 est.","193","Africa"
|
||||||
|
"Zambia","zambia","$3,300","2020 est.","194","Africa"
|
||||||
|
"Timor-Leste","timor-leste","$3,200","2020 est.","195","East Asia/Southeast Asia"
|
||||||
|
"Comoros","comoros","$3,100","2020 est.","196","Africa"
|
||||||
|
"Syria","syria","$2,900","2015 est.","197","Middle East"
|
||||||
|
"Haiti","haiti","$2,800","2020 est.","198","Central America"
|
||||||
|
"Vanuatu","vanuatu","$2,800","2020 est.","199","Australia - Oceania"
|
||||||
|
"Guinea","guinea","$2,700","2020 est.","200","Africa"
|
||||||
|
"Zimbabwe","zimbabwe","$2,700","2020 est.","201","Africa"
|
||||||
|
"Tanzania","tanzania","$2,600","2020 est.","202","Africa"
|
||||||
|
"Solomon Islands","solomon-islands","$2,500","2020 est.","203","Australia - Oceania"
|
||||||
|
"Yemen","yemen","$2,500","2017 est.","204","Middle East"
|
||||||
|
"Ethiopia","ethiopia","$2,300","2020 est.","205","Africa"
|
||||||
|
"Kiribati","kiribati","$2,300","2020 est.","206","Australia - Oceania"
|
||||||
|
"Lesotho","lesotho","$2,300","2020 est.","207","Africa"
|
||||||
|
"Burkina Faso","burkina-faso","$2,200","2020 est.","208","Africa"
|
||||||
|
"Gambia, The","gambia-the","$2,200","2020 est.","209","Africa"
|
||||||
|
"Mali","mali","$2,200","2020 est.","210","Africa"
|
||||||
|
"Uganda","uganda","$2,200","2020 est.","211","Africa"
|
||||||
|
"Rwanda","rwanda","$2,100","2020 est.","212","Africa"
|
||||||
|
"Togo","togo","$2,100","2020 est.","213","Africa"
|
||||||
|
"Afghanistan","afghanistan","$2,000","2020 est.","214","South Asia"
|
||||||
|
"Guinea-Bissau","guinea-bissau","$1,800","2020 est.","215","Africa"
|
||||||
|
"Korea, North","korea-north","$1,700","2015 est.","216","East Asia/Southeast Asia"
|
||||||
|
"Eritrea","eritrea","$1,600","2017 est.","217","Africa"
|
||||||
|
"Sierra Leone","sierra-leone","$1,600","2020 est.","218","Africa"
|
||||||
|
"South Sudan","south-sudan","$1,600","2017 est.","219","Africa"
|
||||||
|
"Chad","chad","$1,500","2020 est.","220","Africa"
|
||||||
|
"Madagascar","madagascar","$1,500","2020 est.","221","Africa"
|
||||||
|
"Malawi","malawi","$1,500","2020 est.","222","Africa"
|
||||||
|
"Liberia","liberia","$1,400","2020 est.","223","Africa"
|
||||||
|
"Mozambique","mozambique","$1,200","2020 est.","224","Africa"
|
||||||
|
"Niger","niger","$1,200","2020 est.","225","Africa"
|
||||||
|
"Congo, Democratic Republic of the","congo-democratic-republic-of-the","$1,100","2020 est.","226","Africa"
|
||||||
|
"Central African Republic","central-african-republic","$900","2020 est.","227","Africa"
|
||||||
|
"Somalia","somalia","$800","2020 est.","228","Africa"
|
||||||
|
"Burundi","burundi","$700","2020 est.","229","Africa"
|
||||||
|
1
Laboratorio11/input.txt
Normal file
1
Laboratorio11/input.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
Faccio sesso e mi drogo tutto il giorno codando in C++
|
||||||
95
Laboratorio11/maze.py
Normal file
95
Laboratorio11/maze.py
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
fio = open("maze.txt", "r")
|
||||||
|
|
||||||
|
maze_raw = fio.readlines()
|
||||||
|
|
||||||
|
fio.close()
|
||||||
|
|
||||||
|
xmax = len(maze_raw) - 1
|
||||||
|
ymax = len(maze_raw[0].strip()) - 1
|
||||||
|
|
||||||
|
maze = {}
|
||||||
|
sol = {}
|
||||||
|
for x in range(len(maze_raw)):
|
||||||
|
for y in range(len(maze_raw[x].strip())):
|
||||||
|
paths = set()
|
||||||
|
|
||||||
|
if x > 0:
|
||||||
|
if maze_raw[x - 1][y] == " ":
|
||||||
|
paths.add((x - 1, y))
|
||||||
|
|
||||||
|
if y > 0:
|
||||||
|
if maze_raw[x][y - 1] == " ":
|
||||||
|
paths.add((x, y - 1))
|
||||||
|
|
||||||
|
if maze_raw[x][y] == " ":
|
||||||
|
paths.add((x, y))
|
||||||
|
|
||||||
|
if y < ymax:
|
||||||
|
if maze_raw[x][y + 1] == " ":
|
||||||
|
paths.add((x, y + 1))
|
||||||
|
|
||||||
|
if x < xmax:
|
||||||
|
if maze_raw[x + 1][y] == " ":
|
||||||
|
paths.add((x + 1, y))
|
||||||
|
|
||||||
|
if len(paths) != 0:
|
||||||
|
maze[(x,y)] = paths
|
||||||
|
|
||||||
|
if maze_raw[x][y] == "*":
|
||||||
|
sol[(x,y)] = "*"
|
||||||
|
else:
|
||||||
|
sol[(x,y)] = "?"
|
||||||
|
|
||||||
|
for key in maze:
|
||||||
|
if key[0] == 0:
|
||||||
|
if maze_raw[key[0]][key[1]] == " ":
|
||||||
|
sol[key] = "N"
|
||||||
|
|
||||||
|
if key[0] == xmax:
|
||||||
|
if maze_raw[key[0]][key[1]] == " ":
|
||||||
|
sol[key] = "S"
|
||||||
|
|
||||||
|
if key[1] == 0:
|
||||||
|
if maze_raw[key[0]][key[1]] == " ":
|
||||||
|
sol[key] = "W"
|
||||||
|
|
||||||
|
if key[1] == ymax:
|
||||||
|
if maze_raw[key[0]][key[1]] == " ":
|
||||||
|
sol[key] = "E"
|
||||||
|
|
||||||
|
cont = True
|
||||||
|
|
||||||
|
def check(xi, yi):
|
||||||
|
global sol
|
||||||
|
return (xi, yi) in sol and sol[xi, yi] != "?" and sol[xi, yi] != "*"
|
||||||
|
|
||||||
|
while cont:
|
||||||
|
cont = False
|
||||||
|
for key in maze:
|
||||||
|
if sol[key] == "?":
|
||||||
|
if check(key[0] - 1, key[1]):
|
||||||
|
sol[key] = "N"
|
||||||
|
cont = True
|
||||||
|
continue
|
||||||
|
|
||||||
|
if check(key[0] + 1, key[1]):
|
||||||
|
sol[key] = "S"
|
||||||
|
cont = True
|
||||||
|
continue
|
||||||
|
|
||||||
|
if check(key[0], key[1] - 1):
|
||||||
|
sol[key] = "W"
|
||||||
|
cont = True
|
||||||
|
continue
|
||||||
|
|
||||||
|
if check(key[0], key[1] + 1):
|
||||||
|
sol[key] = "E"
|
||||||
|
cont = True
|
||||||
|
continue
|
||||||
|
|
||||||
|
|
||||||
|
for x in range(xmax+1):
|
||||||
|
for y in range(ymax+1):
|
||||||
|
print(sol[(x,y)],end="")
|
||||||
|
|
||||||
|
print()
|
||||||
9
Laboratorio11/maze.txt
Normal file
9
Laboratorio11/maze.txt
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
* *******
|
||||||
|
* * * *
|
||||||
|
* ***** *
|
||||||
|
* * * *
|
||||||
|
* * *** *
|
||||||
|
* * *
|
||||||
|
***** * *
|
||||||
|
* * *
|
||||||
|
******* *
|
||||||
22
Laboratorio11/nazioniPIL.py
Normal file
22
Laboratorio11/nazioniPIL.py
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
import csv
|
||||||
|
|
||||||
|
with open("export.csv") as csv_file:
|
||||||
|
csv_reader = csv.reader(csv_file)
|
||||||
|
|
||||||
|
line_count = 0
|
||||||
|
|
||||||
|
nations = {}
|
||||||
|
|
||||||
|
for row in csv_reader:
|
||||||
|
if line_count == 0:
|
||||||
|
print(f'Column names are {", ".join(row)}')
|
||||||
|
line_count += 1
|
||||||
|
else:
|
||||||
|
nations[row[0]] = row[2]
|
||||||
|
|
||||||
|
while True:
|
||||||
|
uinput = input("Inserisci il nome della nazione o quit: ")
|
||||||
|
if uinput == "quit":
|
||||||
|
break
|
||||||
|
|
||||||
|
print(nations[uinput])
|
||||||
1
Laboratorio11/output.txt
Normal file
1
Laboratorio11/output.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
Faccio ***** e mi drogo tutto il giorno codando in ***
|
||||||
33
Laboratorio11/sparseSum.py
Normal file
33
Laboratorio11/sparseSum.py
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
def sparseArraySum(a: dict, b: dict):
|
||||||
|
vsum = {}
|
||||||
|
|
||||||
|
ka = a.keys()
|
||||||
|
kb = b.keys()
|
||||||
|
|
||||||
|
sas = set()
|
||||||
|
|
||||||
|
for i in ka:
|
||||||
|
sas.add(i)
|
||||||
|
|
||||||
|
for i in kb:
|
||||||
|
sas.add(i)
|
||||||
|
|
||||||
|
for k in sas:
|
||||||
|
d = 0
|
||||||
|
e = 0
|
||||||
|
|
||||||
|
if k in a:
|
||||||
|
d = a[k]
|
||||||
|
|
||||||
|
if k in b:
|
||||||
|
e = b[k]
|
||||||
|
|
||||||
|
vsum[k] = d + e
|
||||||
|
|
||||||
|
return vsum
|
||||||
|
|
||||||
|
|
||||||
|
da = {5:4, 9:2, 10:9}
|
||||||
|
db = {5:4, 9:2, 2:3}
|
||||||
|
|
||||||
|
print(sparseArraySum(da, db))
|
||||||
16449
Laboratorio11/test
Normal file
16449
Laboratorio11/test
Normal file
File diff suppressed because it is too large
Load Diff
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: "))
|
||||||
|
|
||||||
2
Laboratorio4/elreverso.py
Normal file
2
Laboratorio4/elreverso.py
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
parola = input("Inserisci una parola: ")
|
||||||
|
print(parola[::-1])
|
||||||
18
Laboratorio4/forme.py
Normal file
18
Laboratorio4/forme.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
n = int(input("Inserisci n: "))
|
||||||
|
|
||||||
|
for x in range(n):
|
||||||
|
print("*"*n)
|
||||||
|
|
||||||
|
print()
|
||||||
|
|
||||||
|
d = 2*n
|
||||||
|
for x in range(0, d-1):
|
||||||
|
a = 1 + x*2
|
||||||
|
|
||||||
|
if a > d - 1:
|
||||||
|
a = d - 1 - (x - n + 1)*2
|
||||||
|
|
||||||
|
b = (d - 1 - a)
|
||||||
|
c = int(b/2)
|
||||||
|
|
||||||
|
print(" "*c + "*"*a + " "*c)
|
||||||
38
Laboratorio4/listanumeri.py
Normal file
38
Laboratorio4/listanumeri.py
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
|
||||||
|
pari = 0
|
||||||
|
dispari = 0
|
||||||
|
somma = 0
|
||||||
|
|
||||||
|
maxN = None
|
||||||
|
minN = None
|
||||||
|
lval = None
|
||||||
|
|
||||||
|
while True:
|
||||||
|
ri = input("Inserisci un numero: ")
|
||||||
|
|
||||||
|
if ri == "":
|
||||||
|
break
|
||||||
|
|
||||||
|
i = int(ri)
|
||||||
|
|
||||||
|
if maxN is None or maxN < i:
|
||||||
|
maxN = i
|
||||||
|
|
||||||
|
if minN is None or minN > i:
|
||||||
|
minN = i
|
||||||
|
|
||||||
|
if i % 2 == 0:
|
||||||
|
pari += 1
|
||||||
|
else:
|
||||||
|
dispari += 1
|
||||||
|
|
||||||
|
somma += i
|
||||||
|
print("Somma parziale: ", somma)
|
||||||
|
|
||||||
|
if lval == i:
|
||||||
|
print("Duplicato: ", lval)
|
||||||
|
else:
|
||||||
|
lval = i
|
||||||
|
|
||||||
|
print("Valore minimo:", minN)
|
||||||
|
print("Valore massimo:", maxN)
|
||||||
31
Laboratorio4/nim.py
Normal file
31
Laboratorio4/nim.py
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
from math import floor, log2
|
||||||
|
from random import randint
|
||||||
|
|
||||||
|
biglie = randint(10, 100)
|
||||||
|
giocaComputer = randint(0, 1) == 1
|
||||||
|
intelligente = randint(0, 1) == 1
|
||||||
|
|
||||||
|
while biglie > 0:
|
||||||
|
if giocaComputer:
|
||||||
|
if intelligente:
|
||||||
|
if biglie in [3, 7, 15, 31, 63]:
|
||||||
|
biglie -= randint(1, floor(biglie/2))
|
||||||
|
else:
|
||||||
|
biglie -= 3
|
||||||
|
else:
|
||||||
|
biglie -= randint(1, floor(biglie/2))
|
||||||
|
else:
|
||||||
|
mbiglie = int(input("Quante biglie vuoi togliere? "))
|
||||||
|
if mbiglie > floor(biglie/2):
|
||||||
|
print("Non puoi togliere così tante biglie")
|
||||||
|
continue
|
||||||
|
|
||||||
|
biglie -= mbiglie
|
||||||
|
|
||||||
|
giocaComputer = not giocaComputer
|
||||||
|
|
||||||
|
|
||||||
|
if giocaComputer:
|
||||||
|
print("Ha vinto il computer")
|
||||||
|
else:
|
||||||
|
print("Ha vinto il giocatore")
|
||||||
24
Laboratorio4/primi.py
Normal file
24
Laboratorio4/primi.py
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
import random
|
||||||
|
|
||||||
|
primeList = []
|
||||||
|
|
||||||
|
|
||||||
|
def primeListGenerator(upperBound):
|
||||||
|
global primeList
|
||||||
|
|
||||||
|
for i in range(2, upperBound):
|
||||||
|
isPrime = True
|
||||||
|
|
||||||
|
for primeNumber in primeList:
|
||||||
|
if i % primeNumber == 0:
|
||||||
|
isPrime = False
|
||||||
|
break
|
||||||
|
|
||||||
|
if isPrime:
|
||||||
|
primeList.append(i)
|
||||||
|
|
||||||
|
|
||||||
|
n = int(input("Fino a "))
|
||||||
|
primeListGenerator(n)
|
||||||
|
for n in primeList:
|
||||||
|
print(n)
|
||||||
32
Laboratorio4/stringheACaso.py
Normal file
32
Laboratorio4/stringheACaso.py
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
stringa = input("Inserisci una stringa: ")
|
||||||
|
|
||||||
|
for char in stringa:
|
||||||
|
if char.isupper():
|
||||||
|
print(char, end="")
|
||||||
|
|
||||||
|
print()
|
||||||
|
|
||||||
|
for char in range(1, len(stringa), 2):
|
||||||
|
print(stringa[char], end="")
|
||||||
|
|
||||||
|
print()
|
||||||
|
|
||||||
|
for char in stringa:
|
||||||
|
if char.lower() in "aeiou":
|
||||||
|
print("_", end="")
|
||||||
|
else:
|
||||||
|
print(char, end="")
|
||||||
|
|
||||||
|
print()
|
||||||
|
|
||||||
|
sumCifre = 0
|
||||||
|
for char in stringa:
|
||||||
|
if char.isdigit():
|
||||||
|
sumCifre += 1
|
||||||
|
|
||||||
|
print("Numero di cifre: ", sumCifre)
|
||||||
|
|
||||||
|
print("Posizioni delle vocali: ", end="")
|
||||||
|
for char in range(len(stringa)):
|
||||||
|
if stringa[char].lower() in "aeiou":
|
||||||
|
print(char, end=" ")
|
||||||
5
Laboratorio4/substrings.py
Normal file
5
Laboratorio4/substrings.py
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
stringa = input("Inserisci una stringa")
|
||||||
|
|
||||||
|
for subLen in range(1, len(stringa)+1):
|
||||||
|
for ns in range(len(stringa)-subLen+1):
|
||||||
|
print(stringa[ns:ns + subLen])
|
||||||
11
Laboratorio5/fattorizzazione.py
Normal file
11
Laboratorio5/fattorizzazione.py
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
n = 12345678901234567890 #int(input("Numero: "))
|
||||||
|
|
||||||
|
k = 2
|
||||||
|
|
||||||
|
while n > 1:
|
||||||
|
for x in range(k,n+1):
|
||||||
|
if n % x == 0:
|
||||||
|
print(x)
|
||||||
|
k = x
|
||||||
|
n = int(n/x)
|
||||||
|
break
|
||||||
30
Laboratorio5/fattorizzazionecrivellata.py
Normal file
30
Laboratorio5/fattorizzazionecrivellata.py
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
primeList = []
|
||||||
|
lastIndex = 2
|
||||||
|
|
||||||
|
def primeListGenerator():
|
||||||
|
global primeList, lastIndex
|
||||||
|
|
||||||
|
isPrime = True
|
||||||
|
|
||||||
|
for primeNumber in primeList:
|
||||||
|
if lastIndex % primeNumber == 0:
|
||||||
|
isPrime = False
|
||||||
|
break
|
||||||
|
|
||||||
|
if isPrime:
|
||||||
|
primeList.append(lastIndex)
|
||||||
|
|
||||||
|
lastIndex += 1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
n = 12345678901234567890 # int(input("Numero: "))
|
||||||
|
|
||||||
|
k = 2
|
||||||
|
|
||||||
|
while n > 1:
|
||||||
|
primeListGenerator()
|
||||||
|
prime = primeList[-1]
|
||||||
|
while n % prime == 0:
|
||||||
|
n = int(n/prime)
|
||||||
|
print(prime)
|
||||||
19
Laboratorio5/lefrancesi.py
Normal file
19
Laboratorio5/lefrancesi.py
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
eccezioni = ["Belize", "Cambodge", "Mexique", "Mozambique", "Zaïre", "Zimbabwe"]
|
||||||
|
|
||||||
|
def main():
|
||||||
|
nazione = input("Nome nazione")
|
||||||
|
|
||||||
|
if nazione == "Etats-Unis" or nazione == "Pays-Bas":
|
||||||
|
print("les", nazione)
|
||||||
|
return
|
||||||
|
|
||||||
|
if nazione[0].lower() in "aeiou":
|
||||||
|
print("l'", nazione)
|
||||||
|
return
|
||||||
|
|
||||||
|
if nazione in eccezioni or nazione[-1] != "e":
|
||||||
|
print("le", nazione)
|
||||||
|
else:
|
||||||
|
print("la", nazione)
|
||||||
|
|
||||||
|
main()
|
||||||
17
Laboratorio5/pin.py
Normal file
17
Laboratorio5/pin.py
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
def main():
|
||||||
|
pin = "1234"
|
||||||
|
errCount = 0
|
||||||
|
|
||||||
|
while errCount < 3:
|
||||||
|
uinput = input("Insert pin: ")
|
||||||
|
|
||||||
|
if uinput == pin:
|
||||||
|
print("Your PIN is correct")
|
||||||
|
return
|
||||||
|
|
||||||
|
print("Your PIN is incorrect")
|
||||||
|
errCount += 1
|
||||||
|
|
||||||
|
print("You bank card is blocked")
|
||||||
|
|
||||||
|
main()
|
||||||
20
Laboratorio5/predatorepreda.py
Normal file
20
Laboratorio5/predatorepreda.py
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
A = float(input("Parametro A: "))
|
||||||
|
B = float(input("Parametro B: "))
|
||||||
|
C = float(input("Parametro C: "))
|
||||||
|
D = float(input("Parametro D: "))
|
||||||
|
|
||||||
|
prede = float(input("Prede: "))
|
||||||
|
predatori = float(input("Predatori: "))
|
||||||
|
|
||||||
|
intervalli = float(input("Iterazioni: "))
|
||||||
|
|
||||||
|
for i in range(intervalli):
|
||||||
|
prede *= 1+A-B*predatori
|
||||||
|
predatori *= 1-C+D*prede
|
||||||
|
|
||||||
|
if prede < 0:
|
||||||
|
print("Prede estinte all'iterazione ", i)
|
||||||
|
if predatori < 0:
|
||||||
|
print("Predatori estinti all'iterazione ", i)
|
||||||
|
|
||||||
|
print("Predatori ", predatori, "; prede ", prede)
|
||||||
21
Laboratorio5/prevendita.py
Normal file
21
Laboratorio5/prevendita.py
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
bigliettiRimasti = 100
|
||||||
|
acquirenti = 0
|
||||||
|
|
||||||
|
while bigliettiRimasti > 0:
|
||||||
|
biglietti = int(input("Quanti biglietti vuoi acquistare? "))
|
||||||
|
|
||||||
|
if biglietti < 1:
|
||||||
|
print("Non puoi vendere biglietti")
|
||||||
|
continue
|
||||||
|
if biglietti > 4:
|
||||||
|
print("Non puoi acquistare più di quattro biglietti")
|
||||||
|
continue
|
||||||
|
elif bigliettiRimasti < biglietti:
|
||||||
|
print("Non sono disponibili abbastanza biglietti")
|
||||||
|
continue
|
||||||
|
|
||||||
|
print("Acquisto effettuato")
|
||||||
|
acquirenti += 1
|
||||||
|
bigliettiRimasti -= biglietti
|
||||||
|
|
||||||
|
print("Acquirenti", acquirenti)
|
||||||
10
Laboratorio5/pseudorandom.py
Normal file
10
Laboratorio5/pseudorandom.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
def pseudorandom(a, b, m, r):
|
||||||
|
while True:
|
||||||
|
r = (a*r+b)%m
|
||||||
|
yield r
|
||||||
|
|
||||||
|
rold = int(input("Seed the generator: "))
|
||||||
|
generator = pseudorandom(32310901, 1729, 2**24, rold)
|
||||||
|
|
||||||
|
for i in range (100):
|
||||||
|
print(next(generator))
|
||||||
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()
|
||||||
24
Laboratorio7/esercizio1.py
Normal file
24
Laboratorio7/esercizio1.py
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
from random import randint
|
||||||
|
|
||||||
|
def main():
|
||||||
|
numbs = []
|
||||||
|
|
||||||
|
for i in range(10):
|
||||||
|
numbs.append(randint(1, 100))
|
||||||
|
|
||||||
|
|
||||||
|
print("Numeri con indici pari", numbs[1::2])
|
||||||
|
#for i in range(0, len(numbs), 2):
|
||||||
|
# print(i,":", numbs[i])
|
||||||
|
|
||||||
|
print("Numeri pari")
|
||||||
|
for i in range(len(numbs)):
|
||||||
|
if numbs[i] % 2 == 0:
|
||||||
|
print(i,":", numbs[i])
|
||||||
|
|
||||||
|
print("Lista invertita", numbs[::-1])
|
||||||
|
|
||||||
|
print("Primo elemento", numbs[0])
|
||||||
|
print("Ultimo elemento", numbs[-1])
|
||||||
|
|
||||||
|
main()
|
||||||
19
Laboratorio7/esercizio2.py
Normal file
19
Laboratorio7/esercizio2.py
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
su = 0
|
||||||
|
op = True
|
||||||
|
|
||||||
|
while True:
|
||||||
|
inp = input("Inserisci un numero: ")
|
||||||
|
|
||||||
|
if inp == "":
|
||||||
|
break
|
||||||
|
|
||||||
|
inp = int(inp)
|
||||||
|
|
||||||
|
if op:
|
||||||
|
su += inp
|
||||||
|
else:
|
||||||
|
su -= inp
|
||||||
|
|
||||||
|
op = not op
|
||||||
|
|
||||||
|
print("La somma alternata è", su)
|
||||||
33
Laboratorio7/esercizio3.py
Normal file
33
Laboratorio7/esercizio3.py
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
def removeDup(a):
|
||||||
|
i=0
|
||||||
|
while i < len(a) - 1:
|
||||||
|
if a[i] == a[i + 1]:
|
||||||
|
a.pop(i)
|
||||||
|
else:
|
||||||
|
i += 1
|
||||||
|
|
||||||
|
|
||||||
|
def sameSet(a, b):
|
||||||
|
cpa = list(a)
|
||||||
|
cpb = list(b)
|
||||||
|
|
||||||
|
cpa.sort()
|
||||||
|
cpb.sort()
|
||||||
|
|
||||||
|
removeDup(cpa)
|
||||||
|
removeDup(cpb)
|
||||||
|
|
||||||
|
if len(cpa) == len(cpb):
|
||||||
|
i=0
|
||||||
|
while i < len(cpa):
|
||||||
|
if cpa[i] != cpb[i]:
|
||||||
|
break
|
||||||
|
|
||||||
|
i += 1
|
||||||
|
|
||||||
|
if i == len(cpa):
|
||||||
|
return True
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
|
print(sameSet([1,5,2,4,4,8], [1,1,4,2,8,5,5]))
|
||||||
13
Laboratorio7/esercizio4.py
Normal file
13
Laboratorio7/esercizio4.py
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
from random import randint
|
||||||
|
|
||||||
|
numbs = []
|
||||||
|
|
||||||
|
for i in range(20):
|
||||||
|
numbs.append(randint(0, 99))
|
||||||
|
print(i,":", numbs[i])
|
||||||
|
|
||||||
|
|
||||||
|
numbs.sort()
|
||||||
|
|
||||||
|
for i in range(len(numbs)):
|
||||||
|
print(i,":", numbs[i])
|
||||||
26
Laboratorio7/esercizio5.py
Normal file
26
Laboratorio7/esercizio5.py
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
|
||||||
|
def readInts():
|
||||||
|
ints = []
|
||||||
|
|
||||||
|
while True:
|
||||||
|
num = input("Inserisci un numero: ")
|
||||||
|
if num == "":
|
||||||
|
break
|
||||||
|
|
||||||
|
ints.append(int(num))
|
||||||
|
|
||||||
|
return ints
|
||||||
|
|
||||||
|
def main():
|
||||||
|
nums = readInts()
|
||||||
|
maxFound=False
|
||||||
|
|
||||||
|
for i in range(1, len(nums) -1):
|
||||||
|
if nums[i-1] < nums[i] > nums[i+1]:
|
||||||
|
print("Massimo locale all'indice", i)
|
||||||
|
maxFound = True
|
||||||
|
|
||||||
|
if not maxFound:
|
||||||
|
print("Non ho trovato massimi locali")
|
||||||
|
|
||||||
|
main()
|
||||||
3
Laboratorio7/esercizio6.py
Normal file
3
Laboratorio7/esercizio6.py
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
def sum_without_smallest(a):
|
||||||
|
mini = min(a)
|
||||||
|
return sum(a) - mini
|
||||||
29
Laboratorio7/esercizio7.py
Normal file
29
Laboratorio7/esercizio7.py
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
def correzione(a):
|
||||||
|
bb = a[0]
|
||||||
|
a[0] = (a[0] + a[1]) / 2
|
||||||
|
|
||||||
|
for i in range(1, len(a)-1):
|
||||||
|
xx = a[i]
|
||||||
|
a[i] = (bb + a[i] + a[i+1])/3
|
||||||
|
bb = xx
|
||||||
|
|
||||||
|
a[len(a)-1] = (bb + a[len(a)-1])/2
|
||||||
|
|
||||||
|
def readInts():
|
||||||
|
ints = []
|
||||||
|
|
||||||
|
while True:
|
||||||
|
num = input("Inserisci un numero: ")
|
||||||
|
if num == "":
|
||||||
|
break
|
||||||
|
|
||||||
|
ints.append(int(num))
|
||||||
|
|
||||||
|
return ints
|
||||||
|
|
||||||
|
def main():
|
||||||
|
a = readInts()
|
||||||
|
correzione(a)
|
||||||
|
print(a)
|
||||||
|
|
||||||
|
main()
|
||||||
44
Laboratorio7/esercizio8.py
Normal file
44
Laboratorio7/esercizio8.py
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
|
||||||
|
def readInts():
|
||||||
|
ints = []
|
||||||
|
|
||||||
|
while True:
|
||||||
|
num = input("Inserisci un numero: ")
|
||||||
|
if num == "":
|
||||||
|
break
|
||||||
|
|
||||||
|
ints.append(int(num))
|
||||||
|
|
||||||
|
return ints
|
||||||
|
|
||||||
|
def main():
|
||||||
|
nums = readInts()
|
||||||
|
maxFound=False
|
||||||
|
|
||||||
|
maxes = []
|
||||||
|
|
||||||
|
for i in range(1, len(nums) -1):
|
||||||
|
if nums[i-1] < nums[i] > nums[i+1]:
|
||||||
|
print("Massimo locale all'indice", i)
|
||||||
|
maxes.append(i)
|
||||||
|
maxFound = True
|
||||||
|
|
||||||
|
if not maxFound:
|
||||||
|
print("Non ho trovato massimi locali")
|
||||||
|
return
|
||||||
|
|
||||||
|
if len(maxes) < 2:
|
||||||
|
print("Ho trovato solo un massimo")
|
||||||
|
return
|
||||||
|
|
||||||
|
a = maxes[0]
|
||||||
|
b = maxes[1]
|
||||||
|
|
||||||
|
for i in range(2, len(maxes)):
|
||||||
|
if maxes[i] - b < b - a:
|
||||||
|
a = b
|
||||||
|
b = maxes[i]
|
||||||
|
|
||||||
|
print("Gli indici dei due massimi più vicini fra loro sono", a, b)
|
||||||
|
|
||||||
|
main()
|
||||||
27
Laboratorio8/esercizio1.py
Normal file
27
Laboratorio8/esercizio1.py
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
def removeDup(a):
|
||||||
|
i=0
|
||||||
|
while i < len(a) - 1:
|
||||||
|
if a[i] == a[i + 1]:
|
||||||
|
a.pop(i)
|
||||||
|
else:
|
||||||
|
i += 1
|
||||||
|
|
||||||
|
|
||||||
|
def sameElements(a, b):
|
||||||
|
cpa = sorted(a)
|
||||||
|
cpb = sorted(b)
|
||||||
|
|
||||||
|
if len(cpa) == len(cpb):
|
||||||
|
i=0
|
||||||
|
while i < len(cpa):
|
||||||
|
if cpa[i] != cpb[i]:
|
||||||
|
break
|
||||||
|
|
||||||
|
i += 1
|
||||||
|
|
||||||
|
if i == len(cpa):
|
||||||
|
return True
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
|
print(sameElements([1,5,2,4,8], [1,4,2,8,5]))
|
||||||
21
Laboratorio8/esercizio2.py
Normal file
21
Laboratorio8/esercizio2.py
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
|
||||||
|
def retNumOrZero(values, row, column):
|
||||||
|
if 0 > row or row >= len(values) or 0 > column or row >= len(values[0]):
|
||||||
|
return None
|
||||||
|
|
||||||
|
return values[row][column]
|
||||||
|
|
||||||
|
def neighborAverage(values, row, column):
|
||||||
|
nums = [retNumOrZero(values, row - 1, column - 1), retNumOrZero(values, row - 1, column), retNumOrZero(values, row - 1, column + 1), retNumOrZero(values, row, column - 1), retNumOrZero(values, row, column), retNumOrZero(values, row, column + 1), retNumOrZero(values, row + 1, column - 1), retNumOrZero(values, row + 1, column), retNumOrZero(values, row + 1, column + 1)]
|
||||||
|
su = 0
|
||||||
|
d = 0
|
||||||
|
for n in nums:
|
||||||
|
if n is not None:
|
||||||
|
su += n
|
||||||
|
d += 1
|
||||||
|
|
||||||
|
print(su / d, end="\t")
|
||||||
|
|
||||||
|
a = [[0,1,2],[3,4,5],[6,7,8]]
|
||||||
|
|
||||||
|
neighborAverage(a, 0, 0)
|
||||||
0
Laboratorio8/esercizio3.py
Normal file
0
Laboratorio8/esercizio3.py
Normal file
33
Laboratorio9/Esercizio4.py
Normal file
33
Laboratorio9/Esercizio4.py
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
def nameOfBestCustomer(sales: list, customers: list):
|
||||||
|
maxSale = sales[0]
|
||||||
|
maxName = customers[0]
|
||||||
|
|
||||||
|
assert len(sales) == len(customers)
|
||||||
|
|
||||||
|
for i in range(1, len(sales)):
|
||||||
|
if maxSale < sales[i]:
|
||||||
|
maxSale = sales[i]
|
||||||
|
maxName = customers[i]
|
||||||
|
|
||||||
|
return maxName
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
sales = []
|
||||||
|
customers = []
|
||||||
|
|
||||||
|
while True:
|
||||||
|
sale = int(input("Inserisci la spesa: "))
|
||||||
|
|
||||||
|
if sale == 0:
|
||||||
|
break
|
||||||
|
|
||||||
|
name = input("Inserisci il nome del cliente: ")
|
||||||
|
|
||||||
|
sales.append(sale)
|
||||||
|
customers.append(name)
|
||||||
|
|
||||||
|
print(nameOfBestCustomer(sales, customers))
|
||||||
|
|
||||||
|
|
||||||
|
main()
|
||||||
79
Laboratorio9/esercizio1.py
Normal file
79
Laboratorio9/esercizio1.py
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
def scambiaEstremi(a: list):
|
||||||
|
c = a[0]
|
||||||
|
a[0] = a[-1]
|
||||||
|
a[-1] = c
|
||||||
|
|
||||||
|
|
||||||
|
def ruotaDestra(a: list):
|
||||||
|
c = a.pop()
|
||||||
|
a.insert(0, c)
|
||||||
|
|
||||||
|
|
||||||
|
def azzeraPari(a: list):
|
||||||
|
for i in range(0, len(a), 2):
|
||||||
|
a[i] = 0
|
||||||
|
|
||||||
|
|
||||||
|
def maxL(a: list):
|
||||||
|
b = a.copy()
|
||||||
|
|
||||||
|
for i in range(1, len(a) - 1):
|
||||||
|
b[i] = max(a[i-1], a[i+1])
|
||||||
|
|
||||||
|
|
||||||
|
def rimuoviCentrale(a: list):
|
||||||
|
if len(a) % 2 == 0:
|
||||||
|
mi = len(a) // 2
|
||||||
|
a.pop(mi - 1)
|
||||||
|
a.pop(mi - 1)
|
||||||
|
return
|
||||||
|
|
||||||
|
mi = len(a) // 2
|
||||||
|
a.pop(mi - 1)
|
||||||
|
|
||||||
|
|
||||||
|
def pariInizio(a: list):
|
||||||
|
x = 0
|
||||||
|
for i in range(0, len(a), 2):
|
||||||
|
a.insert(x, a.pop(i))
|
||||||
|
x += 1
|
||||||
|
|
||||||
|
|
||||||
|
def secondMax(a: list):
|
||||||
|
if a[0] > a[1]:
|
||||||
|
fmax = a[0]
|
||||||
|
smax = a[1]
|
||||||
|
else:
|
||||||
|
fmax = a[1]
|
||||||
|
smax = a[0]
|
||||||
|
|
||||||
|
for i in range(2, len(a)):
|
||||||
|
if a[i] > fmax:
|
||||||
|
smax = fmax
|
||||||
|
fmax = a[i]
|
||||||
|
elif a[i] > smax:
|
||||||
|
smax = a[i]
|
||||||
|
|
||||||
|
return smax
|
||||||
|
|
||||||
|
|
||||||
|
def isListOrdered(a: list):
|
||||||
|
b = sorted(a)
|
||||||
|
|
||||||
|
for i in range(len(a)):
|
||||||
|
if a[i] != b[i]:
|
||||||
|
return False
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def twoAdiacentDuplicates(a: list):
|
||||||
|
for i in range(0, len(a) - 1):
|
||||||
|
if i[0] == i[1]:
|
||||||
|
return True
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def twoDuplicates(a: list):
|
||||||
|
return twoAdiacentDuplicates(sorted(a))
|
||||||
37
Laboratorio9/esercizio2.py
Normal file
37
Laboratorio9/esercizio2.py
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
posti = [[10 , 20, 30], [10 , 20, 30], [10 , 20, 30]]
|
||||||
|
|
||||||
|
def searchInTable(prezzo):
|
||||||
|
for i in range(len(posti)):
|
||||||
|
for j in range(len(posti[i])):
|
||||||
|
if posti[i][j] == prezzo:
|
||||||
|
posti[i][j] = 0
|
||||||
|
print("Posto prenotato con colonna", i, "riga", j)
|
||||||
|
return
|
||||||
|
|
||||||
|
print("Nessun posto prenotabile con quel prezzo")
|
||||||
|
|
||||||
|
while True:
|
||||||
|
ch = input("Vuoi inserire il posto o il prezzo? (posto/prezzo) ")
|
||||||
|
|
||||||
|
if ch == "posto":
|
||||||
|
x = int(input("Inserisci la colonna: "))
|
||||||
|
y = int(input("Inserisci la riga: "))
|
||||||
|
|
||||||
|
if x > len(posti) or x < 0:
|
||||||
|
print("Colonna non valida")
|
||||||
|
continue
|
||||||
|
|
||||||
|
if y > len(posti[x]) or y < 0:
|
||||||
|
print("Riga non valida")
|
||||||
|
continue
|
||||||
|
|
||||||
|
if posti[x][y] == 0:
|
||||||
|
print("Il posto è già occupato")
|
||||||
|
continue
|
||||||
|
|
||||||
|
posti[x][y] = 0
|
||||||
|
print("Posto prenotato")
|
||||||
|
|
||||||
|
else:
|
||||||
|
prezzo = input("Inserisci il prezzo: ")
|
||||||
|
searchInTable(prezzo)
|
||||||
15
Laboratorio9/esercizio3.py
Normal file
15
Laboratorio9/esercizio3.py
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
def play():
|
||||||
|
words = []
|
||||||
|
words.append(input("Inserisci una parola: "))
|
||||||
|
|
||||||
|
while True:
|
||||||
|
print(words)
|
||||||
|
word = input("Inserisci una parola: ")
|
||||||
|
|
||||||
|
if words[-1][-2:] == word[0:2] and word not in words:
|
||||||
|
words.append(word)
|
||||||
|
else:
|
||||||
|
print("Fine dei giochi")
|
||||||
|
return
|
||||||
|
|
||||||
|
play()
|
||||||
58
Laboratorio9/esercizio5.py
Normal file
58
Laboratorio9/esercizio5.py
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
def remMin(a: list):
|
||||||
|
x = 0
|
||||||
|
y = a[0]
|
||||||
|
|
||||||
|
for i in range(len(a)):
|
||||||
|
if y > a[i]:
|
||||||
|
y = a[i]
|
||||||
|
x = i
|
||||||
|
|
||||||
|
a.pop(x)
|
||||||
|
|
||||||
|
|
||||||
|
def remMax(a: list):
|
||||||
|
x = 0
|
||||||
|
y = a[0]
|
||||||
|
|
||||||
|
for i in range(len(a)):
|
||||||
|
if y < a[i]:
|
||||||
|
y = a[i]
|
||||||
|
x = i
|
||||||
|
|
||||||
|
a.pop(x)
|
||||||
|
|
||||||
|
|
||||||
|
def remOdd(a: list):
|
||||||
|
for i in range(len(a)-1, -1, -1):
|
||||||
|
if a[i] % 2 == 1:
|
||||||
|
a.pop(i)
|
||||||
|
|
||||||
|
|
||||||
|
def remLenNotTwo(a: list):
|
||||||
|
for i in range(len(a)-1, -1, -1):
|
||||||
|
if 10 > a[i] or a[i] > 99:
|
||||||
|
a.pop(i)
|
||||||
|
|
||||||
|
|
||||||
|
def printlistf(a):
|
||||||
|
print(":".join(list(map(lambda n: str(n), a))))
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
nums = list(map(lambda n: int(n), input("Inserisci la lista di numeri: ").split(":")))
|
||||||
|
|
||||||
|
a1 = nums.copy()
|
||||||
|
remMax(a1)
|
||||||
|
remMin(a1)
|
||||||
|
printlistf(a1)
|
||||||
|
|
||||||
|
a2 = nums.copy()
|
||||||
|
remOdd(a2)
|
||||||
|
printlistf(a2)
|
||||||
|
|
||||||
|
a3 = nums.copy()
|
||||||
|
remLenNotTwo(a3)
|
||||||
|
printlistf(a3)
|
||||||
|
|
||||||
|
|
||||||
|
main()
|
||||||
60
blackjack.py
Normal file
60
blackjack.py
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
from random import randint
|
||||||
|
|
||||||
|
cardArray = []
|
||||||
|
|
||||||
|
|
||||||
|
def resetDeck():
|
||||||
|
global cardArray
|
||||||
|
cardArray = []
|
||||||
|
for i in range(1, 9):
|
||||||
|
for x in range(4):
|
||||||
|
cardArray.append(i)
|
||||||
|
|
||||||
|
for x in range(12):
|
||||||
|
cardArray.append(10)
|
||||||
|
|
||||||
|
|
||||||
|
def genCard():
|
||||||
|
global cardArray
|
||||||
|
n = randint(0, len(cardArray) - 1)
|
||||||
|
x = cardArray[n]
|
||||||
|
cardArray.pop(n)
|
||||||
|
return x
|
||||||
|
|
||||||
|
|
||||||
|
while True:
|
||||||
|
resetDeck()
|
||||||
|
|
||||||
|
computerSum = genCard()
|
||||||
|
print("La carta scoperta del banco è ", computerSum)
|
||||||
|
computerSum += genCard()
|
||||||
|
|
||||||
|
playerSum = genCard() + genCard()
|
||||||
|
|
||||||
|
while True:
|
||||||
|
print("La somma delle tue carte è pari a ", playerSum)
|
||||||
|
if playerSum > 21:
|
||||||
|
print("Hai perso")
|
||||||
|
break
|
||||||
|
|
||||||
|
cont = input("Hit or stay? ") == "hit"
|
||||||
|
if cont:
|
||||||
|
playerSum += genCard()
|
||||||
|
else:
|
||||||
|
break
|
||||||
|
|
||||||
|
if playerSum > 21:
|
||||||
|
print("\n"*4)
|
||||||
|
continue
|
||||||
|
|
||||||
|
while computerSum < 17:
|
||||||
|
computerSum += genCard()
|
||||||
|
|
||||||
|
print("La somma delle carte del banco è ", computerSum)
|
||||||
|
|
||||||
|
if computerSum > 21 or playerSum > computerSum:
|
||||||
|
print("Hai vinto")
|
||||||
|
else:
|
||||||
|
print("Hai perso")
|
||||||
|
|
||||||
|
print("\n"*4)
|
||||||
36
generatorePassword.py
Normal file
36
generatorePassword.py
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
from random import randint
|
||||||
|
from string import ascii_letters, digits
|
||||||
|
|
||||||
|
spChars = "+-*/?!"
|
||||||
|
|
||||||
|
|
||||||
|
def insert(string, char, index):
|
||||||
|
return string[0:index] + char + string[index+1:len(string)]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def randomCharFromArray(array):
|
||||||
|
return array[randint(0,len(array)-1)]
|
||||||
|
|
||||||
|
|
||||||
|
def makePassword(length):
|
||||||
|
password = ""
|
||||||
|
|
||||||
|
for _ in range(length):
|
||||||
|
password += randomCharFromArray(ascii_letters)
|
||||||
|
|
||||||
|
randIndex1 = randint(0,len(password)-1)
|
||||||
|
password = insert(password, randomCharFromArray(digits), randIndex1) #[randIndex1] = randomCharFromArray(digits)
|
||||||
|
|
||||||
|
randIndex2 = randint(0,len(password)-2)
|
||||||
|
if randIndex1 == randIndex2:
|
||||||
|
randIndex2 = len(password) - 1
|
||||||
|
password = insert(password, randomCharFromArray(spChars), randIndex2)
|
||||||
|
return password
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
length = int(input("Insert password length"))
|
||||||
|
print("Your password is", makePassword(length))
|
||||||
|
|
||||||
|
main()
|
||||||
4
indexdata.txt
Normal file
4
indexdata.txt
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
type:6
|
||||||
|
type:2
|
||||||
|
aa:12
|
||||||
|
fd:2
|
||||||
22
indice.py
Normal file
22
indice.py
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
from sys import exit
|
||||||
|
|
||||||
|
from wordutils import clean
|
||||||
|
|
||||||
|
index = {}
|
||||||
|
|
||||||
|
try:
|
||||||
|
inf = open("indexdata.txt", "r")
|
||||||
|
except FileNotFoundError:
|
||||||
|
exit("File not found")
|
||||||
|
|
||||||
|
for line in inf:
|
||||||
|
fields = line.split(":")
|
||||||
|
key = fields[0].strip()
|
||||||
|
word = fields[1].strip()
|
||||||
|
|
||||||
|
if key not in index:
|
||||||
|
index[key] = set()
|
||||||
|
|
||||||
|
index[key].add(word)
|
||||||
|
|
||||||
|
print(index)
|
||||||
16
kilometri.py
Normal file
16
kilometri.py
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
print("Programma per calcolare le percentuali di uso di una macchina")
|
||||||
|
|
||||||
|
d=float(input("distanza casa lavoro:"))
|
||||||
|
KmI=float(input("chilometraggio iniziale: "))
|
||||||
|
KmF=float(input("chilometraggio finale: "))
|
||||||
|
|
||||||
|
n=int(input("N. giorni lavorativi: "))
|
||||||
|
KmL = 2*d*n
|
||||||
|
|
||||||
|
TotKm= KmF-KmI
|
||||||
|
|
||||||
|
KmP = TotKm-KmL
|
||||||
|
|
||||||
|
print("percentuale Km per lavoro: ", KmL/TotKm*100)
|
||||||
|
|
||||||
|
print("Percentuale Km per uso personale:", KmP/TotKm*100)
|
||||||
7
printTriangolo.py
Normal file
7
printTriangolo.py
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
n = int(input("Inserisci un numero: "))
|
||||||
|
|
||||||
|
for i in range(1, n + 1, 2):
|
||||||
|
spaces = n - i
|
||||||
|
smez = int(spaces/2)
|
||||||
|
|
||||||
|
print(" "*smez+"*"*i+" "*smez)
|
||||||
14
pymontecarlo.py
Normal file
14
pymontecarlo.py
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
from random import random
|
||||||
|
|
||||||
|
n = 100000000
|
||||||
|
|
||||||
|
din = 0
|
||||||
|
|
||||||
|
for i in range(n):
|
||||||
|
x = random()
|
||||||
|
y = random()
|
||||||
|
|
||||||
|
if x**2 + y**2 <= 1:
|
||||||
|
din += 1
|
||||||
|
|
||||||
|
print((din / n)*4)
|
||||||
14
removeDuplicates.py
Normal file
14
removeDuplicates.py
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
def removeDuplicates(st: str):
|
||||||
|
st = list(st)
|
||||||
|
letters = set()
|
||||||
|
|
||||||
|
i = 0
|
||||||
|
|
||||||
|
while i < len(st):
|
||||||
|
if st[i] in letters:
|
||||||
|
st.pop(i)
|
||||||
|
else:
|
||||||
|
letters.add(st[i])
|
||||||
|
i += 1
|
||||||
|
|
||||||
|
return "".join(st)
|
||||||
19
scacchi.py
Normal file
19
scacchi.py
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
while True:
|
||||||
|
casella = input("Inserire casella es g15")
|
||||||
|
|
||||||
|
lettera = casella[0]
|
||||||
|
numero = int(casella[1])
|
||||||
|
|
||||||
|
if lettera in "abcdefgh" and 0 <= numero <= 8:
|
||||||
|
break
|
||||||
|
|
||||||
|
if lettera in "aceg":
|
||||||
|
if numero % 2 == 0:
|
||||||
|
print("Bianco")
|
||||||
|
else:
|
||||||
|
print("Nero")
|
||||||
|
else:
|
||||||
|
if numero % 2 == 1:
|
||||||
|
print("Bianco")
|
||||||
|
else:
|
||||||
|
print("Nero")
|
||||||
44
simulazioni/astrologia/main.py
Normal file
44
simulazioni/astrologia/main.py
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
import csv
|
||||||
|
|
||||||
|
segni = {}
|
||||||
|
somma = 0
|
||||||
|
|
||||||
|
with open("zodiaco.csv") as csv_file:
|
||||||
|
csv_reader = csv.reader(csv_file)
|
||||||
|
|
||||||
|
for row in csv_reader:
|
||||||
|
data_start = row[1]
|
||||||
|
data_start = data_start.split("/")
|
||||||
|
data_start = int(data_start[1] + data_start[0])
|
||||||
|
|
||||||
|
data_end = row[2]
|
||||||
|
data_end = data_end.split("/")
|
||||||
|
data_end = int(data_end[1] + data_end[0])
|
||||||
|
|
||||||
|
nome = row[0]
|
||||||
|
|
||||||
|
segni[nome] = {"start": data_start, "end": data_end, "goals": 0}
|
||||||
|
|
||||||
|
|
||||||
|
with open("sportivi.csv") as csv_file:
|
||||||
|
csv_reader = csv.reader(csv_file)
|
||||||
|
|
||||||
|
for row in csv_reader:
|
||||||
|
data = row[1]
|
||||||
|
data = data.split("/")
|
||||||
|
data = int(data[1] + data[0])
|
||||||
|
|
||||||
|
goals = row[0]
|
||||||
|
|
||||||
|
for segno in segni:
|
||||||
|
if segni[segno]["start"] < data < segni[segno]["end"]:
|
||||||
|
segni[segno]["goals"] += goals
|
||||||
|
somma += goals
|
||||||
|
break
|
||||||
|
|
||||||
|
|
||||||
|
for segno in segni:
|
||||||
|
dati = segni[segno]
|
||||||
|
barra = "*"*int((dati[goals] / somma) * 50)
|
||||||
|
|
||||||
|
print(f"${segno} (${dati['goals']}): ${barra}")
|
||||||
4
simulazioni/discografia/acdc.txt
Normal file
4
simulazioni/discografia/acdc.txt
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
1978;Kicked In The Teeth
|
||||||
|
1985;Playing with Girls
|
||||||
|
1985;Shake Your Foundations
|
||||||
|
1990;Thunderstruck
|
||||||
3
simulazioni/discografia/artisti.txt
Normal file
3
simulazioni/discografia/artisti.txt
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
01023;queen.txt
|
||||||
|
02346;kiss.txt
|
||||||
|
16750;acdc.txt
|
||||||
3
simulazioni/discografia/kiss.txt
Normal file
3
simulazioni/discografia/kiss.txt
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
1980;Two Sides of the Coin
|
||||||
|
1985;King Of The Mountain
|
||||||
|
1979;I Was Made for Lovin' You
|
||||||
31
simulazioni/discografia/main.py
Normal file
31
simulazioni/discografia/main.py
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
songs = dict()
|
||||||
|
|
||||||
|
artists = open("artisti.txt", "r")
|
||||||
|
|
||||||
|
for artist in artists:
|
||||||
|
artist = artist.split(";")
|
||||||
|
artCode = artist[0].strip()
|
||||||
|
|
||||||
|
songsFile = open(artist[1].strip(), "r")
|
||||||
|
|
||||||
|
for song in songsFile:
|
||||||
|
song = song.split(";", 1)
|
||||||
|
year = song[0]
|
||||||
|
title = song[1].strip()
|
||||||
|
|
||||||
|
if year not in songs:
|
||||||
|
songs[year] = []
|
||||||
|
|
||||||
|
songs[year].append({"artist": artCode, "title": title})
|
||||||
|
|
||||||
|
songsFile.close()
|
||||||
|
|
||||||
|
artists.close()
|
||||||
|
|
||||||
|
years = sorted(list(songs.keys()))
|
||||||
|
|
||||||
|
for year in years:
|
||||||
|
print(year + ":")
|
||||||
|
|
||||||
|
for s in songs[year]:
|
||||||
|
print(s["title"] + "\t" + s["artist"])
|
||||||
3
simulazioni/discografia/queen.txt
Normal file
3
simulazioni/discografia/queen.txt
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
1980;Crazy Little Thing Called Love
|
||||||
|
1985;It’s a kind of magic
|
||||||
|
1978;Under pressure
|
||||||
9
simulazioni/hacking/acquisti.txt
Normal file
9
simulazioni/hacking/acquisti.txt
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
P234HF22223 r1112
|
||||||
|
P111TG11115 r1015
|
||||||
|
P111TG11115 r1216
|
||||||
|
P234HF22222 r1011
|
||||||
|
P331LS00110 r1014
|
||||||
|
P331LS00120 r1318
|
||||||
|
P331LS00130 r1019
|
||||||
|
P234HF22225 r1114
|
||||||
|
P234HF22223 r1114
|
||||||
71
simulazioni/hacking/hacking.py
Normal file
71
simulazioni/hacking/hacking.py
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
from sys import exit
|
||||||
|
|
||||||
|
def carica_prodotti(filename: str):
|
||||||
|
try:
|
||||||
|
fio = open(filename, "r")
|
||||||
|
|
||||||
|
prodotti = dict()
|
||||||
|
|
||||||
|
for line in fio:
|
||||||
|
line = line.strip().split()
|
||||||
|
prodotti[line[0]] = line[1]
|
||||||
|
|
||||||
|
fio.close()
|
||||||
|
return prodotti
|
||||||
|
except FileNotFoundError:
|
||||||
|
exit("Errore! Il file", filename, "non è stato trovato!")
|
||||||
|
|
||||||
|
|
||||||
|
def carica_acquisti(filename: str, prodotti: dict):
|
||||||
|
try:
|
||||||
|
fio = open(filename, "r")
|
||||||
|
|
||||||
|
prodotti_sospetti = dict()
|
||||||
|
|
||||||
|
for line in fio:
|
||||||
|
line = line.strip().split()
|
||||||
|
prodotto = line[0]
|
||||||
|
rivenditore = line[1]
|
||||||
|
|
||||||
|
if prodotto not in prodotti:
|
||||||
|
print("Attenzione! il prodotto", prodotto, "non esiste")
|
||||||
|
continue
|
||||||
|
|
||||||
|
if prodotto not in prodotti_sospetti:
|
||||||
|
prodotti_sospetti[prodotto] = []
|
||||||
|
|
||||||
|
prodotti_sospetti[prodotto].append(rivenditore)
|
||||||
|
|
||||||
|
fio.close()
|
||||||
|
return prodotti_sospetti
|
||||||
|
except FileNotFoundError:
|
||||||
|
exit("Errore! Il file", filename, "non è stato trovato!")
|
||||||
|
|
||||||
|
|
||||||
|
def controlla_acquisti(prodotti: dict, acquisti: dict):
|
||||||
|
prodotti_sospetti = dict()
|
||||||
|
for prodotto in acquisti:
|
||||||
|
if len(acquisti[prodotto]) > 1 or (len(acquisti[prodotto]) == 1 and acquisti[prodotto][0] != prodotti[prodotto]):
|
||||||
|
prodotti_sospetti[prodotto] = acquisti[prodotto]
|
||||||
|
|
||||||
|
return prodotti_sospetti
|
||||||
|
|
||||||
|
|
||||||
|
def stampa_prodotti_sospetti(prodotti: dict, prodotti_sospetti: dict):
|
||||||
|
print("Elenco transazioni sospette")
|
||||||
|
for prodotto in prodotti_sospetti:
|
||||||
|
print("Codice prodotto:", prodotto)
|
||||||
|
print("Rivenditore ufficiale:", prodotti[prodotto])
|
||||||
|
print("Lista rivenditori:", " ".join(prodotti_sospetti[prodotto]))
|
||||||
|
print()
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
prodotti = carica_prodotti("prodotti.txt")
|
||||||
|
acquisti = carica_acquisti("acquisti.txt", prodotti)
|
||||||
|
sospetti = controlla_acquisti(prodotti, acquisti)
|
||||||
|
stampa_prodotti_sospetti(prodotti, sospetti)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
8
simulazioni/hacking/prodotti.txt
Normal file
8
simulazioni/hacking/prodotti.txt
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
P234HF22222 r1011
|
||||||
|
P234HF22223 r1112
|
||||||
|
P234HF22225 r1114
|
||||||
|
P111TG11115 r1015
|
||||||
|
P111TG11115 r1216
|
||||||
|
P331LS00110 r1017
|
||||||
|
P331LS00120 r1318
|
||||||
|
P331LS00130 r1019
|
||||||
3
simulazioni/murphy/argomenti.txt
Normal file
3
simulazioni/murphy/argomenti.txt
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
male
|
||||||
|
fretta
|
||||||
|
lavoro
|
||||||
23
simulazioni/murphy/leggi_di_Murphy.txt
Normal file
23
simulazioni/murphy/leggi_di_Murphy.txt
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
Principio degli elementi persi
|
||||||
|
Il raggio di caduta dal banco di lavoro di piccoli elementi varia inversamente alle loro dimensioni - e direttamente alla loro importanza per il completamento del lavoro intrapreso.
|
||||||
|
|
||||||
|
Legge di Perussel
|
||||||
|
Non c'è lavoro tanto semplice che non possa essere fatto male.
|
||||||
|
|
||||||
|
Regola di Ray sulla precisione
|
||||||
|
Misura con un micrometro.
|
||||||
|
Segna con un gessetto.
|
||||||
|
Taglia con un'ascia.
|
||||||
|
|
||||||
|
Legge dei semafori
|
||||||
|
Se è verde non hai fretta.
|
||||||
|
|
||||||
|
Legge di Pudder
|
||||||
|
Chi ben comincia, finisce male. Chi comincia male, finisce peggio.
|
||||||
|
|
||||||
|
Seconda Legge di Horowitz
|
||||||
|
In qualunque momento tu accenda la radio, sentirai le ultime note della tua canzone preferita.
|
||||||
|
|
||||||
|
Legge di Vile sul valore
|
||||||
|
Più un oggetto costa, più lontano bisognerà spedirlo per farlo riparare.
|
||||||
|
|
||||||
67
simulazioni/murphy/murphy.py
Normal file
67
simulazioni/murphy/murphy.py
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
from string import punctuation
|
||||||
|
|
||||||
|
|
||||||
|
def carica_leggi(filename: str):
|
||||||
|
try:
|
||||||
|
fio = open(filename, "r")
|
||||||
|
|
||||||
|
leggi = {}
|
||||||
|
|
||||||
|
titolo = fio.readline()
|
||||||
|
|
||||||
|
while titolo != "":
|
||||||
|
linea = fio.readline()
|
||||||
|
legge = ""
|
||||||
|
|
||||||
|
while linea != "\n" and linea != "":
|
||||||
|
legge += linea.strip()
|
||||||
|
linea = fio.readline()
|
||||||
|
|
||||||
|
leggi[titolo.strip()] = legge
|
||||||
|
|
||||||
|
titolo = fio.readline()
|
||||||
|
|
||||||
|
fio.close()
|
||||||
|
except FileNotFoundError:
|
||||||
|
exit(f"Errore: Il file {filename} non è stato trovato!")
|
||||||
|
except IOError:
|
||||||
|
exit("Errore: Si è verificato un problema durante la lettura del file!")
|
||||||
|
|
||||||
|
return leggi
|
||||||
|
|
||||||
|
|
||||||
|
def carica_argomenti(filename: str):
|
||||||
|
try:
|
||||||
|
fio = open(filename, "r")
|
||||||
|
argomenti = [arg.strip() for arg in fio]
|
||||||
|
fio.close()
|
||||||
|
except FileNotFoundError:
|
||||||
|
exit(f"Errore: Il file {filename} non è stato trovato!")
|
||||||
|
return argomenti
|
||||||
|
|
||||||
|
|
||||||
|
def rimuovi_punteggiatura(stringa: str):
|
||||||
|
for p in punctuation:
|
||||||
|
stringa = stringa.replace(p, " ")
|
||||||
|
|
||||||
|
return stringa
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
leggi = carica_leggi("leggi_di_Murphy.txt")
|
||||||
|
argomenti = carica_argomenti("argomenti.txt")
|
||||||
|
|
||||||
|
for legge in leggi:
|
||||||
|
testo_legge = leggi[legge]
|
||||||
|
parole = rimuovi_punteggiatura(testo_legge.lower()).split()
|
||||||
|
|
||||||
|
for argomento in argomenti:
|
||||||
|
if argomento in parole:
|
||||||
|
if len(testo_legge) > 50:
|
||||||
|
testo_legge = testo_legge[:50] + "..."
|
||||||
|
print(legge, "-", testo_legge)
|
||||||
|
break
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
55
simulazioni/piramidi/main.py
Normal file
55
simulazioni/piramidi/main.py
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
from sys import exit
|
||||||
|
|
||||||
|
def carica_piramide(filename: str):
|
||||||
|
try:
|
||||||
|
fio = open(filename, "r")
|
||||||
|
except FileNotFoundError:
|
||||||
|
exit(f"Attenzione! {filename} non trovato")
|
||||||
|
|
||||||
|
mappa = []
|
||||||
|
|
||||||
|
for i in fio:
|
||||||
|
righa = [int(c) for c in i.strip().split()]
|
||||||
|
mappa.append(righa)
|
||||||
|
|
||||||
|
fio.close()
|
||||||
|
|
||||||
|
return mappa
|
||||||
|
|
||||||
|
|
||||||
|
def lista_adiacenti(mappa: list, x: int, y: int):
|
||||||
|
items = []
|
||||||
|
|
||||||
|
for a in range(max(0, x - 1), min(x + 2, len(mappa))):
|
||||||
|
for b in range(max(0, y - 1), min(y + 2, len(mappa[x]))):
|
||||||
|
if a == x and b == y:
|
||||||
|
continue
|
||||||
|
|
||||||
|
items.append(mappa[a][b])
|
||||||
|
|
||||||
|
return items
|
||||||
|
|
||||||
|
|
||||||
|
def cerca_piramidi(mappa: list):
|
||||||
|
somma_altezze = 0
|
||||||
|
numero_piramidi = 0
|
||||||
|
|
||||||
|
for x in range(len(mappa)):
|
||||||
|
for y in range(len(mappa[x])):
|
||||||
|
altezza_massima = max(lista_adiacenti(mappa, x, y))
|
||||||
|
|
||||||
|
if mappa[x][y] > altezza_massima:
|
||||||
|
print(mappa[x][y], x, y)
|
||||||
|
somma_altezze += mappa[x][y]
|
||||||
|
numero_piramidi += 1
|
||||||
|
|
||||||
|
|
||||||
|
return somma_altezze / numero_piramidi
|
||||||
|
|
||||||
|
def main():
|
||||||
|
mappa = carica_piramide("mappa.txt")
|
||||||
|
media = cerca_piramidi(mappa)
|
||||||
|
print(f"Altezza media: {media} m")
|
||||||
|
|
||||||
|
|
||||||
|
main()
|
||||||
10
simulazioni/piramidi/mappa.txt
Normal file
10
simulazioni/piramidi/mappa.txt
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
3 4 4 4 3 2 1 0 0 0
|
||||||
|
3 4 5 4 3 2 1 1 1 1
|
||||||
|
3 4 4 4 3 2 2 2 2 1
|
||||||
|
3 3 3 3 3 3 3 3 2 1
|
||||||
|
2 2 2 2 2 3 4 3 2 1
|
||||||
|
1 1 1 1 2 3 3 3 2 1
|
||||||
|
0 0 0 1 2 2 2 2 2 1
|
||||||
|
0 0 0 1 1 1 1 1 1 1
|
||||||
|
0 1 0 0 0 0 0 0 0 0
|
||||||
|
0 0 0 0 0 0 1 0 0 0
|
||||||
39
simulazioni/polizia/main.py
Normal file
39
simulazioni/polizia/main.py
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
file = open("presenze.txt", "r")
|
||||||
|
|
||||||
|
presenze = dict()
|
||||||
|
|
||||||
|
for i in file:
|
||||||
|
i = i.split("f")
|
||||||
|
presenza = dict()
|
||||||
|
presenza["number"] = i[1]
|
||||||
|
presenza["start"] = int(i[2])
|
||||||
|
presenza["end"] = int(i[3])
|
||||||
|
presenze[i[0]] = presenza
|
||||||
|
|
||||||
|
file.close()
|
||||||
|
file = open("sospetti.txt", "r")
|
||||||
|
|
||||||
|
for sospetto in file:
|
||||||
|
sospetto = sospetto.strip()
|
||||||
|
if sospetto not in presenze:
|
||||||
|
continue
|
||||||
|
|
||||||
|
inizio = presenze[sospetto]["start"]
|
||||||
|
fine = presenze[sospetto]["end"]
|
||||||
|
|
||||||
|
notFound = True
|
||||||
|
|
||||||
|
print("** Contatti del cliente :", sospetto, "**")
|
||||||
|
|
||||||
|
for nome in presenze:
|
||||||
|
if nome == sospetto:
|
||||||
|
continue
|
||||||
|
|
||||||
|
if min(fine, presenze[nome]["end"]) - max(inizio, presenze[nome]["start"]) > 0:
|
||||||
|
notFound = False
|
||||||
|
print("\tContatto con "+ nome + ", telefono "+presenze[nome]["number"])
|
||||||
|
|
||||||
|
if notFound:
|
||||||
|
print("\tll cliente", sospetto, "non ha avuto contatti")
|
||||||
|
|
||||||
|
file.close()
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user