Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Update 32_stonks.py #121

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
Loading
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 7 additions & 21 deletions 28 6-functions/32_stonks.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,9 @@
# Stonks 📈
# Codédex
# Write code below 💖

stock_prices = [34.68, 36.09, 34.94, 33.97, 34.68, 35.82, 43.41, 44.29, 44.65, 53.56, 49.85, 48.71, 48.71, 49.94, 48.53, 47.03, 46.59, 48.62, 44.21, 47.21]

def price_at(i):
return stock_prices[i-1]

def max_price(a, b):
mx = 0
for i in range(a, b + 1):
mx = max(mx, price_at(i))
return mx

def min_price(a, b):
mn = price_at(a)
for i in range(a, b + 1):
mn = min(mn, price_at(i))
return mn

print(max_price(1, 15))
print(min_price(5, 10))
print(price_at(3))
def price_at(x):
return stock_prices[x-1]
def max_price(a,b):
return max(stock_prices[a-1:b])
def min_prices(a,b):
return min(stock_prices[a-1:b])
Morty Proxy This is a proxified and sanitized view of the page, visit original site.