shivam-python-ext 0.1.0__tar.gz → 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {shivam_python_ext-0.1.0 → shivam_python_ext-0.2.0}/PKG-INFO +1 -1
- {shivam_python_ext-0.1.0 → shivam_python_ext-0.2.0}/pyproject.toml +1 -1
- shivam_python_ext-0.2.0/src/shivam_python_ext/__init__.py +27 -0
- shivam_python_ext-0.1.0/src/shivam_python_ext/__init__.py +0 -2
- {shivam_python_ext-0.1.0 → shivam_python_ext-0.2.0}/README.md +0 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def add(*num):
|
|
5
|
+
sum = 0
|
|
6
|
+
for i in num:
|
|
7
|
+
sum += i
|
|
8
|
+
return sum
|
|
9
|
+
def multiply(*num):
|
|
10
|
+
product = 1
|
|
11
|
+
for i in num:
|
|
12
|
+
product *= i
|
|
13
|
+
return product
|
|
14
|
+
|
|
15
|
+
def main():
|
|
16
|
+
parser=argparse.ArgumentParser(description='Perform addition or multiplication on a list of numbers.')
|
|
17
|
+
parser.add_argument('operation', choices=['add', 'multiply'], help='The operation to perform: add or multiply')
|
|
18
|
+
parser.add_argument('numbers', nargs='+', type=float, help='A list of numbers to perform the operation on')
|
|
19
|
+
args = parser.parse_args()
|
|
20
|
+
if args.operation == 'add':
|
|
21
|
+
result = add(*args.numbers)
|
|
22
|
+
print(f"The sum of the numbers is: {result}")
|
|
23
|
+
elif args.operation == 'multiply':
|
|
24
|
+
result = multiply(*args.numbers)
|
|
25
|
+
print(f"The product of the numbers is: {result}")
|
|
26
|
+
|
|
27
|
+
|
|
File without changes
|