Python dictionary comprehension 🕮

  Рет қаралды 41,671

Bro Code

Bro Code

Күн бұрын

Python dictionary comprehension tutorial example explained
#python #dictionary #comprehension
-------------------------------------------------------------------------
dictionary comprehension = create dictionaries using an expression
can replace for loops and certain lambda functions
# dictionary = {key: expression for (key,value) in iterable}
dictionary = {key: expression for (key,value) in iterable if conditional}
dictionary = {key: (if/else) for (key,value) in iterable}
dictionary = {key: function(value) for (key,value) in iterable}
-------------------------------------------------------------------------
cities_in_F = {'New York': 32, 'Boston': 75, 'Los Angeles': 100, 'Chicago': 50}
cities_in_C = {key: round((value-32)*(5/9)) for (key,value) in cities_in_F.items()}
print(cities_in_C)
-------------------------------------------------------------------------
weather = {'New York': "snowing", 'Boston': "sunny", 'Los Angeles': "sunny", 'Chicago': "cloudy"}
sunny_weather = {key: value for (key,value) in weather.items() if value == "sunny"}
print(sunny_weather)
-------------------------------------------------------------------------
Bro Code merch store 👟 :
===========================================================
teespring.com/...
===========================================================
music credits 🎼 :
===========================================================
Up In My Jam (All Of A Sudden) by - Kubbi / kubbi
Creative Commons - Attribution-ShareAlike 3.0 Unported- CC BY-SA 3.0
Free Download / Stream: bit.ly/2JnDfCE
Music promoted by Audio Library • Up In My Jam (All Of A...
===========================================================

Пікірлер: 80
Python dictionaries are easy 📙
8:06
Bro Code
Рет қаралды 285 М.
10 Python Comprehensions You SHOULD Be Using
21:35
Tech With Tim
Рет қаралды 166 М.
Cheerleader Transformation That Left Everyone Speechless! #shorts
00:27
Fabiosa Best Lifehacks
Рет қаралды 16 МЛН
VIP ACCESS
00:47
Natan por Aí
Рет қаралды 30 МЛН
Mom Hack for Cooking Solo with a Little One! 🍳👶
00:15
5-Minute Crafts HOUSE
Рет қаралды 23 МЛН
“Don’t stop the chances.”
00:44
ISSEI / いっせい
Рет қаралды 62 МЛН
My 10 “Clean” Code Principles (Start These Now)
15:12
Conner Ardman
Рет қаралды 318 М.
ALL 11 Dictionary Methods In Python EXPLAINED
9:26
Indently
Рет қаралды 74 М.
Python Dictionary Comprehension in 20 Minutes
19:30
Ryan & Matt Data Science
Рет қаралды 763
Python *ARGS & **KWARGS are awesome! 📦
14:54
Bro Code
Рет қаралды 89 М.
Python if __name__ == '__main__' ❓
5:41
Bro Code
Рет қаралды 37 М.
List Comprehension - BEST Python feature !!! Fast and Efficient
14:51
Python Simplified
Рет қаралды 200 М.
Please Master These 10 Python Functions…
22:17
Tech With Tim
Рет қаралды 261 М.
Dictionary Comprehension - Create Complex Data Structures Step by Step
21:58
Python Decorators in 15 Minutes
15:14
Kite
Рет қаралды 459 М.
Python lists, sets, and tuples explained 🍍
15:06
Bro Code
Рет қаралды 351 М.
Cheerleader Transformation That Left Everyone Speechless! #shorts
00:27
Fabiosa Best Lifehacks
Рет қаралды 16 МЛН