Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help creating a function called candy_info that returns a 'Candy' object created using a constructor. Here is some info: Question and Solution requirements:

I need help creating a function called candy_info that returns a 'Candy' object created using a constructor.

Here is some info:

Question and Solution requirements:

image text in transcribed

Class Code:

image text in transcribed

Test Code:

image text in transcribed

Thank you for your help and time!

Problem Overview Your task in this homework assignment is to write a function returns the Candy object. Solution Specifications Your solution to this problem must meet the following criteria. 1. You must define a function candy_info in the file candy_function .py that takes a three parameters. - a string for the name of the candy - an int for the number of grams of sugar - a float for the price of the candy 2. The function must return the Candy object. class Candy: def _init__ (self, name, sugar, price): self.name=nameself.sugar=sugarself.price=price import candy_function. \# test the function my_candy = candy function. candy_info("SUGAR DADDY MILK CARAMEL POPS", 24, 10.45) print(my_candy. name) print(my_candy.sugar) print(my_candy.price)

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

MFDBS 91 3rd Symposium On Mathematical Fundamentals Of Database And Knowledge Base Systems Rostock Germany May 6 9 1991

Authors: Bernhard Thalheim ,Janos Demetrovics ,Hans-Detlef Gerhardt

1991st Edition

3540540091, 978-3540540090

More Books

Students also viewed these Databases questions