forked from tdwojak/Python2017
Zadania na zajęciach Labs05
Rozwiązanie - Piotr Bystrzycki - nr indeksu 45146
This commit is contained in:
parent
4c0515a9fa
commit
2e6466143b
@ -1,11 +1,14 @@
|
||||
#!/usr/bin/env python2
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
def suma(liczby):
|
||||
pass
|
||||
s = 0
|
||||
for i in range(len(liczby)):
|
||||
s += float(liczby[i])
|
||||
return s
|
||||
|
||||
def main():
|
||||
print(summa([1, 2, 3, 4]))
|
||||
print(suma([1, 2, 3, 4]))
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
@ -0,0 +1,9 @@
|
||||
import task00 as t0
|
||||
import sys
|
||||
|
||||
def main():
|
||||
liczby = sys.argv[1:]
|
||||
print(t0.suma(liczby))
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
@ -0,0 +1,13 @@
|
||||
import task00 as t0
|
||||
import sys
|
||||
|
||||
def main():
|
||||
liczby = sys.argv[1:]
|
||||
try:
|
||||
print(t0.suma(liczby))
|
||||
except ValueError:
|
||||
print("Wrong types of arguments passed!")
|
||||
raise
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
@ -0,0 +1,20 @@
|
||||
import task00 as t0
|
||||
import sys, argparse
|
||||
|
||||
def main():
|
||||
#liczby = sys.argv[1:]
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("floats", help="Lista liczb zmiennoprzecinkowych", nargs = "+")
|
||||
args = parser.parse_args()
|
||||
|
||||
liczby = args.floats
|
||||
|
||||
try:
|
||||
print(t0.suma(liczby))
|
||||
except ValueError:
|
||||
print("Wrong types of arguments passed!")
|
||||
raise
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Loading…
Reference in New Issue
Block a user