-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBeispiel_Testing.py
More file actions
43 lines (38 loc) · 1.02 KB
/
Beispiel_Testing.py
File metadata and controls
43 lines (38 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/local/bin/python3
##############################################
#
# Name: Beispiel_Testing.py
#
# Author: Peter Christen
#
# Version: 1.1
#
# Date: 10.06.2017
# 04.12.2020 Korrektur angebracht
#
# Purpose: Script mit Testing-Funktion
#
##############################################
import platform,os,time,argparse
####Parameter auswerten
parser = argparse.ArgumentParser(description='Quersumme berechnen')
group = parser.add_mutually_exclusive_group(required=True)
group.add_argument('-s', metavar='Nummern', nargs='+', type=int, help="Zahlen zur Berechnung der Quadratsumme eingeben")
group.add_argument('-t', action='store_true', help="Testmodus")
args = parser.parse_args()
###Funktion
def quersumme(s):
""" Errechnet die Quersumme einer Liste
>>> quersumme ([1, 2, 3]) # 1 + 2 + 3
6
>>> quersumme ([10,20,30]) # 10+20+30
60
"""
return sum(s)
if args.t:
#Testmodus
import doctest
doctest.testmod(verbose=True)
else:
#Normale Funktion
print(quersumme(args.s))