feat: Initial commit
This commit is contained in:
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
|
||||
Reference in New Issue
Block a user