Commit 4152dc6f authored by Emil's avatar Emil
Browse files

Corrections week 1

parent 7114e1e6
import sys
if (not len(sys.argv) == 2):
print("Not enough parameters for the program {0}".format(sys.argv[0]))
sys.exit()
print("sys.argv is of type {0}".format(type(sys.argv)))
prog_name = sys.argv[0]
N = sys.argv[1]
print("{0} says: Hello {1}".format(prog_name, N))
import sys
import series
def main():
if (not len(sys.argv) == 2):
print("Not enough parameters for the program {0}".format(sys.argv[0]))
return
print("sys.argv is of type {0}".format(type(sys.argv)))
prog_name = sys.argv[0]
N = int(sys.argv[1])
print("{0} says: Hello {1} {2}".format(
prog_name, series.computeSeries(N), N*(N+1)/2))
if __name__ == '__main__':
main()
def computeSeries(n):
res = 0
for i in range(1, n+1):
res += i
return res
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment