Command-line programs · 7 / 15 Exercise Easy

Sum of the arguments

Objective

Create a Python program that receives any number of numbers as arguments and shows a summary. The arguments of each test are passed to the program as if you typed them in the terminal (they appear in the test cases).

Instructions

  • Convert each argument of sys.argv[1:] to an integer. If any is not a number, show Invalid argument: text and finish with exit code 2.
  • If there are no arguments, show No numbers.
  • Otherwise show Count: k, Sum: s and Maximum: m.
Output
Count: 3
Sum: 27
Maximum: 15

Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.

Start exercise