update
Some checks failed
It_School_001/pipeline/head Something is wrong with the build of this commit
Some checks failed
It_School_001/pipeline/head Something is wrong with the build of this commit
This commit is contained in:
24
Python_module_2/python_002.py
Executable file
24
Python_module_2/python_002.py
Executable file
@@ -0,0 +1,24 @@
|
||||
#!/home/andrei/it_school/bin/python3
|
||||
|
||||
import sys
|
||||
|
||||
def main():
|
||||
if len(sys.argv) < 4:
|
||||
print("Eroare: Trebuie sa furnizati cel putin trei argumente numerice.")
|
||||
|
||||
numbers = []
|
||||
|
||||
for arg in sys.argv[1:]:
|
||||
try:
|
||||
num = float(arg)
|
||||
numbers.append(num)
|
||||
except ValueError:
|
||||
print(f"Eroare: '{arg}' nu este un numar valid.")
|
||||
return
|
||||
total = sum(numbers)
|
||||
average = total / len(numbers)
|
||||
print(f"Suma: {total}")
|
||||
print(f"Media: {average}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user