Python3 only please. Make a class names Foo Add a class variable to foo called x and initialize it to 5 Add an instance variable to foo called y and initialize it to 100 Make an instance of the class, call it f Using f, print out the value of x Print out the value of  y  Class a class Make a class.  It should be something really offbeat and zany, so I know it’s not a direct example from the Internet.   The most important thing is to write a simple class, create TWO different instances, and then be able to do something.  For example, create a pizza instance for Suzie, ask her for the toppings from the choices, and store her pizza order. Then create a second pizza instance for Larry, ask for his toppings and store his pizza order.  Then print both of their orders back out.  You do not need to make your class very complicated; the point is to just demo the requested items below.  KEEP IT SIMPLE, SHORT AND SWEET IS FINE., remember all you need to do is show the requested features.  Some totally random class ideas are:   A foodie class where you can initialize it to have a few food choices then ask it what you should eat, like custom make a burger, pizza, or order food, drink, ice cream cone, etc. It can be anything as long as it is totally original.  Some imaginary or real math calculations that you invent or a game or fortune thing  Storing your favorite songs/playlist, or creating an artist class and then it stores and lets you add songs to it.    Feel good quotes, you could ask for a quote to make you grateful, it gives you random one, Ask for one to make you feel relaxed, and so on Making suggestions, for example it asks you if you are sick, then asks you about your symptoms and based on that makes a suggestion for a cure. Boyfriend/girlfriend advisor, for example, asks questions then makes suggestions for the appropriate date. Some sort of sports thing, or mind game A crying baby and you can ask it if it is crying, make it cry, and/or ask it for a reason (maybe it has an array of reasons like “I’m hungry” etc and it returns back a reason).     (Your class should have a constructor) Make sure your class has a  constructor that will set some initial properties.  If you are in Python have one constructor and then make one other setter method to re-seed initial values to something different if desired.    (It should have two-three additional functions that do something)  Make sure your class has two functions that do something At least one of the functions needs to  (returns a value) that does something cool. At least one of your procedures (or function) should take a parameter(s).    (Variables)  Make sure your class has one or two variables/attributes    (Data structure) Make sure your class has a simple data structure, for example,  For Python it could be just a list or tuple or set or dictionary.  For example, a list that you add songs to, or a set to store coordinates, or a dictionary of info, etc.  You can pick whatever data structure you want.   Create an instance and demo how it can be used)  Now I want you to create an instance of this class you have created, then calling it’s various methods to prove to me that everything in your class works as you expected.    Create a second instance and demo)  Same thing - just create a second instance. So if you had created an instance of CryingBaby called “Suzie” now you would create a new instance called “Sarah” for example, and again, call the methods you wrote to show me you know how to create a second instance of a class and invoke its various methods.    (Create the demo)

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Python3 only please.

  1. Make a class names Foo
  2. Add a class variable to foo called x and initialize it to 5
  3. Add an instance variable to foo called y and initialize it to 100
  4. Make an instance of the class, call it f
  5. Using f, print out the value of x
  6. Print out the value of  y

 Class a class

Make a class.  It should be something really offbeat and zany, so I know it’s not a direct example from the Internet.   The most important thing is to write a simple class, create TWO different instances, and then be able to do something.  For example, create a pizza instance for Suzie, ask her for the toppings from the choices, and store her pizza order. Then create a second pizza instance for Larry, ask for his toppings and store his pizza order.  Then print both of their orders back out.  You do not need to make your class very complicated; the point is to just demo the requested items below.  KEEP IT SIMPLE, SHORT AND SWEET IS FINE., remember all you need to do is show the requested features.

 Some totally random class ideas are:

  •  
  • A foodie class where you can initialize it to have a few food choices then ask it what you should eat, like custom make a burger, pizza, or order food, drink, ice cream cone, etc. It can be anything as long as it is totally original. 
  • Some imaginary or real math calculations that you invent or a game or fortune thing 
  • Storing your favorite songs/playlist, or creating an artist class and then it stores and lets you add songs to it.  
  •  Feel good quotes, you could ask for a quote to make you grateful, it gives you random one, Ask for one to make you feel relaxed, and so on
  • Making suggestions, for example it asks you if you are sick, then asks you about your symptoms and based on that makes a suggestion for a cure.
  • Boyfriend/girlfriend advisor, for example, asks questions then makes suggestions for the appropriate date.
  • Some sort of sports thing, or mind game
  • A crying baby and you can ask it if it is crying, make it cry, and/or ask it for a reason (maybe it has an array of reasons like “I’m hungry” etc and it returns back a reason). 

 

 (Your class should have a constructor)

Make sure your class has a  constructor that will set some initial properties. 

If you are in Python have one constructor and then make one other setter method to re-seed initial values to something different if desired.

 

 (It should have two-three additional functions that do something) 

Make sure your class has two functions that do something

At least one of the functions needs to  (returns a value) that does something cool. At least one of your procedures (or function) should take a parameter(s). 

 

(Variables) 

Make sure your class has one or two variables/attributes 

 

(Data structure)

Make sure your class has a simple data structure, for example, 

For Python it could be just a list or tuple or set or dictionary.  For example, a list that you add songs to, or a set to store coordinates, or a dictionary of info, etc.  You can pick whatever data structure you want.

 

Create an instance and demo how it can be used) 

Now I want you to create an instance of this class you have created, then calling it’s various methods to prove to me that everything in your class works as you expected. 

 

Create a second instance and demo) 

Same thing - just create a second instance. So if you had created an instance of CryingBaby called “Suzie” now you would create a new instance called “Sarah” for example, and again, call the methods you wrote to show me you know how to create a second instance of a class and invoke its various methods. 

 

(Create the demo) 

You can have a menu interface to your program if you want but you don’t need to. It’s fine to just create the instances directly using hard-coded values, or you can make a menu that gets input from the user but either way create your two instances, have them do something, and print out results and what not.  For example, ask for their favorite artist, then ask them for several songs (or just print available songs you’ve stored) by that artist, then be able to print out the songs.  Or create the artist and let them choose what to play, then print out a lyric,or have them make a custom burger, or make a pizza for them by offering the topics and let them choose,  or decide what fast food to order from a menu of choices.  

 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 6 images

Blurred answer
Knowledge Booster
Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education