Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

finish writing this python code function after your code starts here below. please do not add functions or change the variables, just make it output

finish writing this python code function after "your code starts here" below.

please do not add functions or change the variables, just make it output the correct responses for the test cases.

Also please do not print the results, only return them.

-------------------------------------------------------

import random import math

# -------- SECTION 1 class Pantry: """" >>> sara_pantry = Pantry() >>> sara_pantry.stock_pantry('Bread', 2) 'Pantry Stock for Bread: 2.0' >>> sara_pantry.stock_pantry('Cookies', 6) 'Pantry Stock for Cookies: 6.0' >>> sara_pantry.stock_pantry('Chocolate', 4) 'Pantry Stock for Chocolate: 4.0' >>> sara_pantry.stock_pantry('Pasta', 3) 'Pantry Stock for Pasta: 3.0' >>> sara_pantry I am a Pantry object, my current stock is {'Bread': 2.0, 'Cookies': 6.0, 'Chocolate': 4.0, 'Pasta': 3.0} >>> sara_pantry.get_item('Pasta', 2) 'You have 1.0 of Pasta left' >>> sara_pantry.get_item('Pasta', 6) 'Add Pasta to your shopping list!' >>> sara_pantry I am a Pantry object, my current stock is {'Bread': 2.0, 'Cookies': 6.0, 'Chocolate': 4.0, 'Pasta': 0.0} >>> ben_pantry = Pantry() >>> ben_pantry.stock_pantry('Cereal', 2) 'Pantry Stock for Cereal: 2.0' >>> ben_pantry.stock_pantry('Noodles', 5) 'Pantry Stock for Noodles: 5.0' >>> ben_pantry.stock_pantry('Cookies', 9) 'Pantry Stock for Cookies: 9.0' >>> ben_pantry.stock_pantry('Cookies', 8) 'Pantry Stock for Cookies: 17.0' >>> ben_pantry.get_item('Pasta', 2) "You don't have Pasta" >>> ben_pantry.get_item('Cookies', 2.5) 'You have 14.5 of Cookies left' >>> sara_pantry.transfer(ben_pantry, 'Cookies') >>> sara_pantry I am a Pantry object, my current stock is {'Bread': 2.0, 'Cookies': 20.5, 'Chocolate': 4.0, 'Pasta': 0.0} >>> ben_pantry.transfer(sara_pantry, 'Rice') >>> ben_pantry.transfer(sara_pantry, 'Pasta') >>> ben_pantry I am a Pantry object, my current stock is {'Cereal': 2.0, 'Noodles': 5.0, 'Cookies': 0.0} >>> ben_pantry.transfer(sara_pantry, 'Pasta') >>> ben_pantry I am a Pantry object, my current stock is {'Cereal': 2.0, 'Noodles': 5.0, 'Cookies': 0.0} >>> sara_pantry I am a Pantry object, my current stock is {'Bread': 2.0, 'Cookies': 20.5, 'Chocolate': 4.0, 'Pasta': 0.0} """

def __init__(self): self.items = {} def __repr__(self): #--- YOUR CODE STARTS HERE

def stock_pantry(self, item, qty): #--- YOUR CODE STARTS HERE

def get_item(self, item, qty): #--- YOUR CODE STARTS HERE

def transfer(self, other_pantry, item): #--- YOUR CODE STARTS HERE

def run_tests(): import doctest doctest.testmod(verbose=True) if __name__ == "__main__": run_tests()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Understanding Oracle APEX 5 Application Development

Authors: Edward Sciore

2nd Edition

1484209893, 9781484209899