Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
python help can you help me turn theses to pythons
#1
scenario 1
build a stock portfolio manager. The manager program will consist of 3 dictionaries.
1.The first dictionary, called Names, maps the stock symbol to the company name (example: "GM" maps to "General Motors").
2.The second dictionary, called Prices, maps the stock symbol to a list of 2 floating point numbers corresponding to the buy price (the price the user paid for the stock) and the current market price (the price the user could sell the stock for today).
3.The third dictionary, called Exposure, maps the stock symbol to a list of 2 floating point numbers, corresponding to the number of shares purchased, and the risk associated with holding onto the stock (i.e. How likely the stock is to gain value in the future).

Your program should consist of the following functions:
•AddName - Asks the user for a Stock Symbol and Name pairing then adds it to the Names dictionary.
•AddPrices - Takes a Stock Symbol as an input parameter, then asks the user for the Buy price and the Current price of the corresponding stock, adding them to the Prices dictionary.
•AddExposure - Takes a Stock Symbol as an input parameter, then asks the user for the Risk and Shares of the corresponding stock, adding them to the Exposure dictionary.
•AddStock - Calls AddName, AddPrices, and AddExposure to add a new stock to the portfolio.
•GetSale - Finds the maximum expected value of selling a stock. The expected sale value of a stock is the current profit minus the future value of the stock: ◦Expected Sale value = ( ( Current Price - Buy Price ) - Risk * CurrentPrice ) * Shares
The GetSale function should calculate this value for each stock in the portfolio, and return the stock symbol with the highest expected sale value.
•Main - Should take no arguments, but present a menu item consisting of "1. Add Stock", "2. Recommend Sale" and "3. Exit". If the user selects '1,' the Add Stock function is called, and when it is complete, the menu is presented again. If the user selects '2,' the Symbol of the stock corresponding to the highest expected value (returned by GetSale) should be displayed, and the menu presented after completion. If the user selects '3', the program should end.

scenario 2
Define a class called Car with the following attributes:
•Total Odometer Miles
•Speed in miles per hour
•Driver Name
•Sponsor

The total odometer miles should be initialized to zero, and speed initialized to a random value between 1 and 120.

Create a list of 20 vehicles with random (or real) driver and sponsor names.

Your main program should simulate the progress of the vehicles in the race. Every minute, the vehicles pick a new random speed, and their odometer miles are updated every minute using this equation:
•odometer_miles = odometer_miles + speed * time

Since speed is in miles per hour, time should be in hours as well (1 minute is 1/60th of an hour).

The first car to reach 500 miles should be declared the winner by printing the driver name and sponsor name.

Include any useful methods in your class definition that you see fit.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Python Help Dεlluzion 3 2,009 09-30-2019, 12:59 AM
Last Post: samsmith001
  Simple Python Python Compiler Canoris 21 9,208 06-01-2011, 06:30 PM
Last Post: Filefinder
  Python 2 vs 3? Jake 8 2,670 12-11-2010, 04:13 PM
Last Post: Bursihido
  Python help Kharnage 2 904 02-12-2010, 09:07 PM
Last Post: Kharnage
  "==" and "is" in Python Canoris 1 852 02-07-2010, 03:55 PM
Last Post: uber1337

Forum Jump:


Users browsing this thread: 1 Guest(s)