1
0
forked from tdwojak/Python2017

Zadania na zajęciach Labs05

Rozwiązanie - Piotr Bystrzycki - nr indeksu 45146
This commit is contained in:
s45146 2017-12-16 12:56:09 +01:00
parent 4c0515a9fa
commit 2e6466143b
4 changed files with 48 additions and 3 deletions

View File

@ -1,11 +1,14 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import sys
def suma(liczby): def suma(liczby):
pass s = 0
for i in range(len(liczby)):
s += float(liczby[i])
return s
def main(): def main():
print(summa([1, 2, 3, 4])) print(suma([1, 2, 3, 4]))
if __name__ == "__main__": if __name__ == "__main__":
main() main()

View File

@ -0,0 +1,9 @@
import task00 as t0
import sys
def main():
liczby = sys.argv[1:]
print(t0.suma(liczby))
if __name__ == "__main__":
main()

View File

@ -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()

View File

@ -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()