-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSys.py
More file actions
22 lines (15 loc) · 716 Bytes
/
Copy pathSys.py
File metadata and controls
22 lines (15 loc) · 716 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#Write a Python program using the sys module that accepts numbers as command-line arguments and prints their sum and average.
import sys # Import sys module to access command-line arguments
# Read numbers from command-line arguments (excluding script name)
# Convert each argument to integer and store in a list
NumberList = list(map(int, sys.argv[1:]))
# Calculate the sum of all numbers in the list
total = sum(NumberList)
# Calculate the average of the numbers
average = total / len(NumberList)
# Display the entered numbers
print("Numbers Entered :: ", NumberList)
# Display the sum of numbers
print("Sum of numbers ::", total)
# Display the average value
print("Average ::", average)