41.3k views
5 votes
1) Create your own module (20 points) Create one Python module: arithmetic which has two functions: add(x, y) and get_length(x). The description of two functions are below: def add(x, y): # add two numbers def get_length(x): # return the length of a given string Then make another Python file: test.py where two functions defined in arithmetic will be imported and called using real arguments. Note: • You need to submit two separate Python files: arithmetic.py and test.py for this question.

1 Answer

1 vote

Answer:

filename: arithmetic.py

code:

def add(x,y):

print(x+y)

def get_length(x):

return len(x)

filename: test.py

code:

import arithmetic

arithmetic.add(17,19)

print(arithmetic.get_length("harry potter"))

#or you can also take some user input

x=int(input("please enter an integer: "))

y=int(input("please enter an integer: "))

arithmetic.add(x,y)

x1=input("please enter any string: ")

print(arithmetic.get_length(x1))

Step-by-step explanation:

User Evette
by
4.9k points