Create one Python module: arithmetic which has two functions: add(x, y) and get_length(x).
The description of two functions are below (hint: name this file arithmetic.py):
def add(x, y):
# add two numbers
def get_length(x):
# return the length of a given string
Then in the main .ipynb file of this assignment, import this arithmetic model, and call these two functions using real arguments.
Note: • You need to also submit the arithmetic.py file this question.
Below is a screen shot of the python program to check indentation. Comments are given on every line explaining the code. arithmetic.py: main file: Below is the output of the program: Below is the code to copy: arithmetic.py: #CODE STARTS HERE----------------
def add(x,y): #Add function return x+y #Returns the sum of x and y def get_length(x): #Get length function # Returns the length of x using built in function len() return len(x) #CODE ENDS HERE------------------
main.py:
#CODE STARTS HERE----------------
import arithmetic #importing arithematic module(arithmetic.py) #Call add function from arithmetic and print result print(arithmetic.add(5,10)) #Call get_length function from arithmetic and print result print(arithmetic.get_length("abcdefg")) #CODE ENDS HERE------------------
Get Answers For Free
Most questions answered within 1 hours.