1
0
forked from ovh/pci-test
This commit is contained in:
dmagro 2025-05-01 18:25:58 +02:00
parent 9ef89a992f
commit 6e7fe656b4
3 changed files with 39 additions and 0 deletions

4
ex1/a.py Normal file
View File

@ -0,0 +1,4 @@
import sys
frase = " ".join(sys.argv[1:])
print("Hai scritto:", frase)

25
ex1/b.py Normal file
View File

@ -0,0 +1,25 @@
import argparse
import sys
VALORI_AMMESSI = {"toto", "tata", "titi"}
parser = argparse.ArgumentParser()
parser.add_argument(
'-t', '--target',
nargs='+',
choices=VALORI_AMMESSI,
help="Specifica da 1 a 3 valori tra: toto, tata, titi.",
required=True
)
# Esegui parsing
args = parser.parse_args()
# Verifica massimo 3 valori
if len(args.target) > 3:
print("Errore: puoi fornire **al massimo 3** valori tra 'toto', 'tata' e 'titi'.", file=sys.stderr)
sys.exit(1)
# Tutto OK
print("Valori accettati:", args.target)

10
ex1/c.py Normal file
View File

@ -0,0 +1,10 @@
import sys
import pyfiglet
if len(sys.argv) < 2:
print("Usa: python script.py 'testo da convertire'")
sys.exit(1)
text = " ".join(sys.argv[1:])
ascii_art = pyfiglet.figlet_format(text)
print(ascii_art)