Functions
Functions
Functions
OBJECTIVES
# Abu Dhabi, 35
# Almaty, 22
# Ankara, 32
# Astana, 1
# Bangkok, 30
# Beijing, 28
# New Delhi, 32
# Osaka, 26
# Pyongyang, 23
# Quezon, 33
filter() function
Write a program that filters cities with below 25 degrees temperature.
# Abu Dhabi, 35
# Almaty, 22
# Ankara, 32
# Astana, 1
# Bangkok, 30
# Beijing, 28
# New Delhi, 32
# Osaka, 26
# Pyongyang, 23
# Quezon, 33
filter() function
map() function
map() is a built-in function that allows you to process and transform all the
items in an iterable without using an explicit for loop, a technique
commonly known as mapping.
map() function
Write a program that converts the following Fahrenheit to Celsius.
[70, 80, 88, 78, 90, 78, 66]; using a function and lambda
Formula: (F-32) * 5/9
map() function
Write a program that converts the following Fahrenheit to Celsius.
Manila 90, Tokyo 77, Seoul 79, Bangkok 87, Jakarta 90
Nested functions
• The functions declared within the scope of another function are called
nested functions.
Generator Functions
• An important class of functions is the generators, which simplifies the
job of writing the iterators.
• It is a routine that is used to manage the iteration behavior of a loop.
Next: Object-oriented programming