Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

python 3please Question 4: Maximum Profit fcr Stock (4 points) Suppose you have stock price history, and you are allowed to buy orly once and

python 3please
image text in transcribed
Question 4: Maximum Profit fcr Stock (4 points) Suppose you have stock price history, and you are allowed to buy orly once and sell only once. Write a function max_profit(prices) that finds the maximum profit you can make. There is no need to buy if no profit is possible. For example, if you have the prices 5, 10, 2, 11, 20], the maximum benefit would be buying at the price 2 and seling at the price 20 which equals to 18 In I : def max profit(prices): Your code here In [ ]: max-profit([10,22 , 17, 23, 15] 13

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_2

Step: 3

blur-text-image_3

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

Databases DeMYSTiFieD

Authors: Andy Oppel

2nd Edition

0071747990, 978-0071747998

More Books

Students also viewed these Databases questions

Question

What is meant by organisational theory ?

Answered: 1 week ago

Question

What is meant by decentralisation of authority ?

Answered: 1 week ago

Question

Briefly explain the qualities of an able supervisor

Answered: 1 week ago

Question

Define policy making?

Answered: 1 week ago

Question

Define co-ordination?

Answered: 1 week ago