Python Programming Tutorial - 53 - Finding Largest or Smallest Items

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

after 3 months finally a "welcome back"

KingMartinelli
Автор

#ask for help#
import heapq
stocks=[
{'ticker':'AAPL', 'price:20'},
{'ticker': 'GOOG', 'price:80'},
{'ticker': 'FB', 'price:45'},
{'ticker': 'MSFT', 'price:313'},
{'ticker': 'TUNA', 'price:68'}
]
print(heapq.nsmallest(2, stocks, key = lambda stock:stock['price']))

the outcome is a NameError: name 'stocks' is not defined. Why?

hmsjrer
Автор

shouldn't you had wrote stock with a 's' at the end after 'key=lambda' ??

baleia
Автор

Can someone tell me the function instead of the lambda? Thank. :)

AbhayAgrawal
Автор

Python Programming Tutorial - 52 - Finding Largest or Smallest Items

jegsmeganu
Автор

you can do this too but it will give you only one value
print(min(Students, key=lambda x: x["avg_Marks"]))

flow
Автор

can anyone know why there is a word "key" in front of lamboda, i tried to use any variable but it can't work

kenchen
Автор

whats wrong with print(min(stocks, key=stocks.get))

prcdjhnsn
Автор

In the output list of tuples, sometimes price is the first value and ticker is the second value. Why is this?

warrencrasta
Автор

list.sort()
#print n latgest elements
n=int(input())
print(list[-1:n]

mallikarjunbr
Автор

no module for healp q tried to search with pip command

gyan
Автор

hi Bucky, may i know that which IDE you are using for running python?

Nukilier
Автор

what kind of laptops or specifications would you recommend for such programming softwares?

LittlePrincess
Автор

who will give a more sufficent detail of the lambda of the video???it just is confusing???

mingyang