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 assignmentpy
In this script, we are going to make five methods:
Create a method named operatenumxy 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 xy The division should include a decimal point.
Create a method named checklistxyz that returns True if the value x is in the list y at
position z
Create a method named sumupx which calculates the sum for all values from to x
inclusively, and returns that value.
Create a method named createdictxy 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 Eg for x abc and y
the dictionary created should be a:b:c: This method should return the created
dictionary.
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
runtests:
num
num
num
listcat 'dog', 'bird', 'bear', 'emu'
list
res operatenumnum num
res checklistnum list num
res sumupnum
res createdictlist list
printres strres
printres strres
printres strresprintres strres
Lastly, include the command to run the tests runtests so that when I call python
assignpy it will run all code in runtests
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
