Question: Open a new Python script in your favorite IDE and name it assignment _ 0 . py In this script, we are going to make

Open a new Python script in your favorite IDE and name it assignment_0.py
In this script, we are going to make five methods:
1.Create a method named operate_num(x,y), which takes two integers as input and returns
a tuple that contains the sum of x and y, the product of x and y, and the float value of the
division (x/y). The division should include a decimal point.
2.Create a method named check_list(x,y,z) that returns True if the value x is in the list y at
position z.
3.Create a method named sum_up(x), which calculates the sum for all values from 0 to x,
inclusively, and returns that value.
4.Create a method named create_dict(x,y), where x and y are lists of the same length. This
method iterates over the two lists and creates a dictionary where the values at index i from
list x are the keys for values at index i from list y. E.g., for x =[a,b,c] and y =[2,3,4],
the dictionary created should be {a:2,b:3,c:4}. This method should return the created
dictionary.
5.Include the following test method at the end of your python script and make sure that all
methods run as expected. You can test with multiple values to check your code. def
run_tests():
num_1=5
num_2=8
num_3=2
list_0=['cat', 'dog', 'bird', 'bear', 'emu']
list_1=[1,3,5,10,20]
res_0= operate_num(num_1, num_2)
res_1= check_list(num_1, list_1, num_3)
res_2= sum_up(num_2)
res_3= create_dict(list_0, list_1)
print("res_0="+ str(res_0))
print("res_1="+ str(res_1))
print("res_2="+ str(res_2))print("res_3="+ str(res_3))
Lastly, include the command to run the tests run_tests(), so that when I call python
assign).py, it will run all code in run_tests()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!