draw objects and labels that python interpreter creates and write a code

User Generated

ubyybcbyyb

Programming

Description

a. This part of the question involves creating two drawings. You can make your drawings whichever way is easiest or fastest for you. For instance, you could simply make your drawings using pencil and paper then scan or photograph them.

Consider the following two assignments.

hobbies = ['football', 'ballet', 'kickboxing']

hobbies[2] = 'judo'

Draw the objects and labels that the Python interpreter creates in response to the first assignment. Then draw the objects and labels that results from carrying out the second assignment immediately after the first assignment.

For examples such drawings:


Include your drawings in the solution document.

b.Part iii of this question involves writing one Python function definition. Open the file TM112_18J_TMA02_Q5_OUCU.py and inspect its contents. Write your Python function definition for number_of_cookies() in this file where indicated. Note that the file already contains code for automatically testing the function number_of_cookies(). Also, when you have completed your work on this question, copy all the contents of this file as text (with indentation preserved) into your solution document.

You are given a certain amount cookie dough. The amount is specified as weight in grams. You are asked to make cookies with a certain radius and height. The volume of a cookie in cm3 is calculated as follows:

Volume = radius x radius x 3.14158 x height

Where radius and height are in cm.

The problem is to write a python function that returns the number of whole cookies you can make with the cookie dough you have been given (measured in grams) and the radius and height of each of the cookies.

Assume that:

  • all cookies have the same radius and height;
  • only whole cookies count (not partial, e.g. half, cookies);
  • 1 cm3 of cookie dough weighs 10 grams.

i.Include your initial decomposition of the problem in your solution document.

ii.Include the algorithm for solving the problem in your solution document.

iii.Provide a Python function that implements the algorithm. Follow the instructions above for submitting code. In answer to this part of the question, you need to submit the .py file with your function (following the instructions provided above) , and also paste a copy of all the code in your file into your solution document as text.

Unformatted Attachment Preview

a. This part of the questoo iovolves creaton two drawions. You cao make your drawions whichever way is easiest or fastest for you. For iostaoce, you could simply make your drawions usion peocil aod paper theo scao or photonraph them. Coosider the followion two assinomeots. hobbies = ['football', 'ballet', 'kickboxion'] hobbies[2] = 'judo' Draw the objects aod labels that the Pythoo ioterpreter creates io respoose to the frst assinomeot. Theo draw the objects aod labels that results from carryion out the secood assinomeot immediately after the frst assinomeot. For examples such drawions: Ioclude your drawions io the solutoo documeot. b.Part iii of this questoo iovolves writon ooe Pythoo fuoctoo defoitoo. .peo the fle TM112_18J_TMA02_Q5_.UCU.py aod iospect its cooteots. Write your Pythoo fuoctoo defoitoo for oumber_of_cookies() io this fle where iodicated. Note that the fle already cootaios code for automatcally teston the fuoctoo oumber_of_cookies(). Also, wheo you have completed your work oo this questoo, copy all the cooteots of this fle as text (with iodeotatoo preserved) ioto your solutoo documeot. You are niveo a certaio amouot cookie dounh. The amouot is specifed as weinht io nrams. You are asked to make cookies with a certaio radius aod heinht. The volume of a cookie io cm3 is calculated as follows: Volume = radius x radius x 3.14158 x heinht Where radius aod heinht are io cm. The problem is to write a pythoo fuoctoo that returos the oumber of whole cookies you cao make with the cookie dounh you have beeo niveo (measured io nrams) aod the radius aod heinht of each of the cookies. Assume that:  all cookies have the same radius aod heinht;  ooly whole cookies couot (oot partal, e.n. half, cookies);  1 cm3 of cookie dounh weinhs 10 nrams. i.Ioclude your ioital decompositoo of the problem io your solutoo documeot. ii.Ioclude the alnorithm for solvion the problem io your solutoo documeot. iii.Provide a Pythoo fuoctoo that implemeots the alnorithm. Follow the iostructoos above for submittion code. Io aoswer to this part of the questoo, you oeed to submit the .py fle with your fuoctoo (followion the iostructoos provided above) , aod also paste a copy of all the code io your fle ioto your solutoo documeot as text. # TM112_18J_TMA02_Q5_OUCU.py def number_of_cookies(grams_of_dough, height_cookie, radius_cookie): """Given the amount of dough available (measured in grams) and the volume of each cookies (given height and radius of cookies in cm), calculate how many cookies can be made with the available dough.""" # INSERT YOUR CODE BELOW THIS LINE FOR CALCULATING THE # NUMBER OF COOKIES AND RETURNING THE RESULT (DO NOT CHANGE # THE HEADER OF THE FUNCTION WHICH HAS BEEN PROVIDED FOR YOU # ABOVE) # DO NOT CHANGE THE CODE BELOW THIS LINE # The code below automatcally tests your functon # following the approach described in Block 2 Part 4 (Page 207 and further). # Before making any changes to this fle, when you run it, you will # get an AssertonError. Once you have completed the fle with correct # code, the AssertonError should no longer appear. def test_number_of_cookies(): """Test the number_of_cookies() functon.""" # Test for 40gr of dough, for cookie that is 0.5cm high and # has a radius of 1cm (return value should be 2) assert number_of_cookies(40, 0.5, 1) == 2 # Test for 400gr of dough, for cookie that is 0.5cm high and # has a radius of 1cm (return value should be 25) assert number_of_cookies(400, 0.5, 1) == 25 # Test for 1200gr of dough, for cookie that is 0.3cm high and # has a radius of 1cm (return value should be 127) assert number_of_cookies(1200, 0.3, 1) == 127 # Test for 0gr of dough, for cookie that is 0.5cm heigh and # has a radius of 1cm (return value should be 0: with 0gr of # cookie dough you can make 0 cookies) assert number_of_cookies(0, 0.5, 1) == 0 test_number_of_cookies()
Purchase answer to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Explanation & Answer

hello, its ...


Anonymous
I was having a hard time with this subject, and this was a great help.

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4

Related Tags