Skip to content

Commit 76eaa8d

Browse files
committed
Finalizado completo
1 parent b6d8df5 commit 76eaa8d

File tree

35 files changed

+251
-10
lines changed

35 files changed

+251
-10
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+
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
spanish_translations = { "dog": "perro", "house": "casa", "cat": "gato" }
2+
# Your code here
3+
4+
5+
# Don't touch the code below
6+
print("Translation:", spanish_translations["dog"])
7+
print(spanish_translations)
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
par = "Lorem ipsum dolor sit amet consectetur adipiscing elit Curabitur eget bibendum turpis Curabitur scelerisque eros ultricies venenatis mi at tempor nisl Integer tincidunt accumsan cursus"
2+
3+
counts = {}
4+
5+
# Your code here
6+
7+
8+
print(counts)
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Your code here
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
parking_state = [
2+
[1,1,1],
3+
[0,0,0],
4+
[1,1,2]
5+
]
6+
7+
# Your code here

.learn/resets/16-Techno_beat/app.py

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
3+
# Your code above, nothing to change after this line
4+
print(lyrics_generator([0,0,1,1,0,0,0]))
5+
print(lyrics_generator([0,0,1,1,1,0,0,0]))
6+
print(lyrics_generator([0,0,0]))
7+
print(lyrics_generator([1,0,1]))
8+
print(lyrics_generator([1,1,1]))

exercises/11-Nested_list/app.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
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-
for i in coordinates
4+
for i in range(0,len(coordinates_list)):
5+
longitude = coordinates_list[i][1]
6+
print(longitude)

exercises/12-Map_a_list/app.py

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

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

78
result = list(map(celsius_to_fahrenheit, celsius_values))
89

exercises/12.1-more_mapping/app.py

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

33
# Your code here
4-
4+
def multiply_by_three(number):
5+
return number*3;
6+
new_list = list(map(multiply_by_three,my_numbers))
57
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-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def calculate_age(date_of_birth):
1515

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

2020

2121
name_list = list(map(format_greeting, people))

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(bool_list):
5+
if bool_list == 1:
6+
return "wiki"
7+
elif bool_list == 0:
8+
return "woko"
49

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

exercises/12.6-Transformers/app.py

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

99
# Your code here
1010

11+
def data_transformer(param_list):
12+
#name = param_list["name"]
13+
#lastname = param_list["last_name"]
14+
#return f"{name} {lastname}"
15+
return list(map(lambda x: f"{x['name']} {x['last_name']}", param_list))
16+
17+
#print(list(map(data_transformer, incoming_ajax_data)))
18+
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

+5-1
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-
4+
def filter_names(name):
5+
return name.startswith("R")
6+
# Optimal solution
7+
#return name[0].lower() == "r"
8+
resulting_names = list(filter(filter_names,all_names))
59
print(resulting_names)
610

711

exercises/13.2-filter_done_tasks/app.py

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

1212

1313
# Your code here
14+
def done_task(task):
15+
return task["done"] == True
1416

17+
new_tasks = list(filter(done_task,tasks))
18+
print(new_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+
5+
def filter_names():
6+
return list(filter(lambda x: 'am' in x.lower(), names))
7+
print(filter_names())

exercises/13.4-Making_HTML_with_filter_and_maP/app.py

+7
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,11 @@
99
]
1010

1111
# Your code here
12+
def generate_li(color):
13+
return f"<li>{color['label']}</li>"
1214

15+
def filter_colors(color):
16+
return color['sexy'] == True
17+
18+
filtered_colors = list(filter(filter_colors, all_colors))
19+
print(list(map(generate_li,filtered_colors)))

exercises/14-Loop-dictionary/app.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
spanish_translations = { "dog": "perro", "house": "casa", "cat": "gato" }
22
# Your code here
3-
3+
spanish_translations["love"]="amor"
4+
spanish_translations["code"]="codigo"
5+
spanish_translations["smart"]="inteligente"
46

57
# Don't touch the code below
68
print("Translation:", spanish_translations["dog"])

exercises/14.1-letter_counter/app.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
counts = {}
44

55
# Your code here
6-
7-
6+
hello = "Hello World"
7+
for letter in par:
8+
if(letter != " "):
9+
letter = letter.lower()
10+
if letter in counts:
11+
counts[letter] += 1
12+
elif letter not in counts:
13+
counts[letter] = 1
14+
815
print(counts)

exercises/15.1-Matrix_Builder/app.py

+11
Original file line numberDiff line numberDiff line change
@@ -1 +1,12 @@
11
# Your code here
2+
def matrix_builder(n):
3+
matrix = []
4+
cols = n
5+
rows = n
6+
for i in range(rows):
7+
row = []
8+
for j in range(cols):
9+
row.append(1)
10+
matrix.append(row)
11+
return matrix
12+
print(matrix_builder(2))

exercises/15.2-Parking_lot_check/app.py

+24
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,27 @@
55
]
66

77
# Your code here
8+
9+
def get_parking_lot(parking):
10+
11+
# 1 = occupied
12+
# 2 = available
13+
# 0 = do not parking spot
14+
state = {
15+
'total_slots' : 0,
16+
'available_slots' : 0,
17+
'occupied_slots' : 0
18+
}
19+
20+
for i in range(len(parking)):
21+
#print(i)
22+
for j in range(len(parking[i])):
23+
#print(j)
24+
if parking[i][j]==1:
25+
state["occupied_slots"] += 1
26+
state["total_slots"] += 1
27+
elif parking[i][j] == 2:
28+
state["available_slots"] += 1
29+
state["total_slots"] += 1
30+
return state
31+
print(get_parking_lot(parking_state))

exercises/16-Techno_beat/app.py

+13
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
def lyrics_generator(lyrics):
2+
song = ""
3+
aux=0
4+
for i in lyrics:
5+
if i == 0:
6+
song += "Boom "
7+
elif i == 1:
8+
song += "Drop the bass "
9+
aux += 1
10+
if aux == 3:
11+
song += "!!!Break the bass!!! "
12+
aux=0
13+
return song
114

215

316
# Your code above, nothing to change after this line

0 commit comments

Comments
 (0)