Skip to content

Commit ea514a9

Browse files
committed
Done till 13.4, tomorrow we will start with 14
1 parent 655d3f7 commit ea514a9

File tree

25 files changed

+154
-7
lines changed

25 files changed

+154
-7
lines changed

.learn/resets/12-Map_a_list/app.py

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
celsius_values = [-2, 34, 56, -10]
2+
3+
def celsius_to_fahrenheit(celsius):
4+
# The magic happens here
5+
6+
7+
result = list(map(celsius_to_fahrenheit, celsius_values))
8+
9+
print(result)
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
my_numbers = [23,234,345,4356234,243,43,56,2]
2+
3+
# Your code here
4+
5+
print(new_list)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
names = ['Alice', 'Bob', 'Marry', 'Joe', 'Hilary', 'Stevia', 'Dylan']
2+
3+
def prepender(name):
4+
return "My name is: " + name
5+
6+
# Your code here
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
mixed_list = ['1','5','45','34','343','34',6556,323]
2+
3+
def type_list(items):
4+
# Your code here
5+
return
6+
7+
new_list = list(map(type_list, mixed_list))
8+
9+
print(new_list)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import datetime
2+
3+
people = [
4+
{ "name": 'Joe', "birth_date": datetime.datetime(1986,10,24) },
5+
{ "name": 'Bob', "birth_date": datetime.datetime(1975,5,24) },
6+
{ "name": 'Erika', "birth_date": datetime.datetime(1989,6,12) },
7+
{ "name": 'Dylan', "birth_date": datetime.datetime(1999,12,14) },
8+
{ "name": 'Steve', "birth_date": datetime.datetime(2003,4,24) }
9+
]
10+
11+
def calculate_age(date_of_birth):
12+
today = datetime.date.today()
13+
age = today.year - date_of_birth.year - ((today.month, today.day) < (date_of_birth.month, date_of_birth.day))
14+
return age
15+
16+
def format_greeting(person):
17+
# Your code here
18+
return person["name"]
19+
20+
21+
name_list = list(map(format_greeting, people))
22+
23+
print(name_list)

.learn/resets/12.5-Yes_and_no/app.py

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
the_bools = [0,1,0,0,1,1,1,0,0,1,0,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,1]
2+
3+
# Your code here
4+
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
incoming_ajax_data = [
2+
{ "name": 'Mario', "last_name": 'Montes' },
3+
{ "name": 'Joe', "last_name": 'Biden' },
4+
{ "name": 'Bill', "last_name": 'Clon' },
5+
{ "name": 'Hilary', "last_name": 'Mccafee' },
6+
{ "name": 'Bobby', "last_name": 'Mc birth' }
7+
]
8+
9+
# Your code here
10+

.learn/resets/13-Filter_list/app.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
all_numbers = [23,12,35,5,3,2,3,54,3,21,534,23,42,1]
2+
3+
4+
def filter_function(item):
5+
# Update here
6+
return item % 2 == 1
7+
8+
greater_than_ten = list(filter(filter_function, all_numbers))
9+
10+
print(greater_than_ten)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
all_names = ["Romario", "Boby", "Roosevelt", "Emiliy", "Michael", "Greta", "Patricia", "Danzalee"]
2+
3+
# Your code here
4+
5+
print(resulting_names)
6+
7+
8+
9+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
tasks = [
2+
{ "label": 'Eat my lunch', "done": True },
3+
{ "label": 'Make the bed', "done": False },
4+
{ "label": 'Have some fun', "done": False },
5+
{ "label": 'Finish the replits', "done": False },
6+
{ "label": 'Replit the finishes', "done": True },
7+
{ "label": 'Ask for a raise', "done": False },
8+
{ "label": 'Read a book', "done": True },
9+
{ "label": 'Make a trip', "done": False }
10+
]
11+
12+
13+
# Your code here
14+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
names = ['Liam','Emma','Noah','Olivia','William','Ava','James','Isabella','Logan','Sophia','Benjamin','Mia','Mason','Charlotte','Elijah','Amelia','Oliver','Evelyn','Jacob','Abigail','Lucas','Harper','Michael','Emily','Alexander','Elizabeth','Ethan','Avery','Daniel','Sofia','Matthew','Ella','Aiden','Madison','Henry','Scarlett','Joseph','Victoria','Jackson','Aria','Samuel','Grace','Sebastian','Chloe','David','Camila','Carter','Penelope','Wyatt','Riley']
2+
3+
# Your code here
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
all_colors = [
2+
{"label": 'Red', "sexy": True},
3+
{"label": 'Pink', "sexy": False},
4+
{"label": 'Orange', "sexy": True},
5+
{"label": 'Brown', "sexy": False},
6+
{"label": 'Pink', "sexy": True},
7+
{"label": 'Violet', "sexy": True},
8+
{"label": 'Purple', "sexy": False},
9+
]
10+
11+
# Your code here
12+

exercises/11-Nested_list/app.py

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
coordinates_list = [[33.747252, -112.633853], [-33.867886, -63.987], [41.303921, -81.901693], [-33.350534, -71.653268]]
22

33
# Your code here
4+
latititud = []
5+
longitude = []
6+
7+
for coor in coordinates_list:
8+
print(coor[1])

exercises/12-Map_a_list/app.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
def celsius_to_fahrenheit(celsius):
44
# The magic happens here
5-
5+
return (celsius * 9/5)+32
66

77
result = list(map(celsius_to_fahrenheit, celsius_values))
8-
98
print(result)

exercises/12.1-more_mapping/app.py

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
my_numbers = [23,234,345,4356234,243,43,56,2]
22

33
# Your code here
4+
# new_list = []
5+
def multiply_by_three(num):
6+
return num*3
47

8+
new_list = list(map(multiply_by_three, my_numbers))
59
print(new_list)

exercises/12.2-Map_function_inside_variable/app.py

+1
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ def prepender(name):
44
return "My name is: " + name
55

66
# Your code here
7+
print(list(map(prepender,names)))

exercises/12.3-Map_data_types/app.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
def type_list(items):
44
# Your code here
5-
return
5+
return type(items)
66

77
new_list = list(map(type_list, mixed_list))
88

exercises/12.4-Map_list_of_objects/app.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ def calculate_age(date_of_birth):
1515

1616
def format_greeting(person):
1717
# Your code here
18-
return person["name"]
19-
18+
return f'Hello, my name is {person["name"]} and I am {calculate_age(person["birth_date"])} years old'
2019

2120
name_list = list(map(format_greeting, people))
2221

exercises/12.5-Yes_and_no/app.py

+6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
the_bools = [0,1,0,0,1,1,1,0,0,1,0,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,1]
22

33
# Your code here
4+
def wiki_woko(number):
5+
if number == 1:
6+
return "wiki"
7+
elif number == 0:
8+
return "woko"
49

10+
print(list(map(wiki_woko, the_bools)))

exercises/12.6-Transformers/app.py

+3
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,7 @@
77
]
88

99
# Your code here
10+
def data_transformer(users):
11+
return list(map(lambda user: f'{user["name"]} {user["last_name"]}', users))
1012

13+
print(data_transformer(incoming_ajax_data))

exercises/13-Filter_list/app.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
def filter_function(item):
55
# Update here
6-
return item % 2 == 1
6+
return item > 10
77

88
greater_than_ten = list(filter(filter_function, all_numbers))
99

exercises/13.1-Filter_and_list/app.py

+4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
all_names = ["Romario", "Boby", "Roosevelt", "Emiliy", "Michael", "Greta", "Patricia", "Danzalee"]
22

33
# Your code here
4+
def starts_with_r(name):
5+
if name[0]=="R":
6+
return name
47

8+
resulting_names = list(filter(starts_with_r,all_names))
59
print(resulting_names)
610

711

exercises/13.2-filter_done_tasks/app.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111

1212

1313
# Your code here
14-
14+
print(list(filter(lambda task : task["done"], tasks)))
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
names = ['Liam','Emma','Noah','Olivia','William','Ava','James','Isabella','Logan','Sophia','Benjamin','Mia','Mason','Charlotte','Elijah','Amelia','Oliver','Evelyn','Jacob','Abigail','Lucas','Harper','Michael','Emily','Alexander','Elizabeth','Ethan','Avery','Daniel','Sofia','Matthew','Ella','Aiden','Madison','Henry','Scarlett','Joseph','Victoria','Jackson','Aria','Samuel','Grace','Sebastian','Chloe','David','Camila','Carter','Penelope','Wyatt','Riley']
22

33
# Your code here
4+
def am_in_name(name):
5+
if "am" in name or "Am" in name:
6+
return name
7+
print(list(filter(am_in_name,names)))

exercises/13.4-Making_HTML_with_filter_and_maP/app.py

+8
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,11 @@
1010

1111
# Your code here
1212

13+
def generate_li(color):
14+
return f'<li>{color["label"]}</li>'
15+
16+
def filter_colors(item):
17+
return item['sexy']
18+
19+
20+
print(list(map(generate_li, list(filter(filter_colors, all_colors)))))

0 commit comments

Comments
 (0)