logo Hurry, Grab up to 30% discount on the entire course
Order Now logo

Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed

expert
Lee BohlGeneral article writing
(5/5)

641 Answers

Hire Me
expert
Milton BlahaaFinance
(5/5)

702 Answers

Hire Me
expert
Chander MohanEngineering
(5/5)

740 Answers

Hire Me
expert
Dan CurnowComputer science
(5/5)

571 Answers

Hire Me
Linear Programming
(5/5)

In a file called finances.py, import Stock from the file stock.py. Create a new stock with a purchase

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

Python Classes Lab

1. In a file called stock.py, make a class Stock with 3 methods and one attribute called value. 

class Stock:

2. A new instance of a Stock object calls the init method below. This initializes the stock’s value to the purchase_price argument, which has a default value of $10000.

    def __init__(self, purchase_price = 10000):

        """Initialize the value."""

        self.value = purchase_price

3. The Stock class needs a method called gain() that generates a random number between 1 and 10, using the randint method from the random standard library. Get this with:

from random import randint amt = randint(1,10)

a. Add the result to the value of the stock.

4. In a file called finances.py, import Stock from the file stock.py. Create a new stock with a purchase price of $50000, and let it gain money for 10 days. At the end of 10 days, print the results. (Stock needs a function to either print or return the value).

You must upload both python files AND a screenshot showing the code running.

(5/5)
Attachments:

Related Questions

. The fundamental operations of create, read, update, and delete (CRUD) in either Python or Java

CS 340 Milestone One Guidelines and Rubric  Overview: For this assignment, you will implement the fundamental operations of create, read, update,

. Develop a program to emulate a purchase transaction at a retail store. This  program will have two classes, a LineItem class and a Transaction class

Retail Transaction Programming Project  Project Requirements:  Develop a program to emulate a purchase transaction at a retail store. This

. The following program contains five errors. Identify the errors and fix them

7COM1028   Secure Systems Programming   Referral Coursework: Secure

. Accepts the following from a user: Item Name Item Quantity Item Price Allows the user to create a file to store the sales receipt contents

Create a GUI program that:Accepts the following from a user:Item NameItem QuantityItem PriceAllows the user to create a file to store the sales receip

. The final project will encompass developing a web service using a software stack and implementing an industry-standard interface. Regardless of whether you choose to pursue application development goals as a pure developer or as a software engineer

CS 340 Final Project Guidelines and Rubric  Overview The final project will encompass developing a web service using a software stack and impleme