From 800bcbf255ef5bd4f0ded32ca8281b368524701d Mon Sep 17 00:00:00 2001 From: Anee Date: Fri, 19 Dec 2025 20:46:56 -0500 Subject: [PATCH] done all of the exercises have passed the tests. --- exercises/01-hello-world/app.py | 1 + exercises/01.1-Access-and-Retrieve/app.py | 4 +++ exercises/01.2-Retrieve-items/app.py | 2 ++ exercises/01.3-Print-the-last-one/app.py | 5 ++-- exercises/01.4-loop-seventeen/app.py | 2 ++ exercises/01.5-Add-item-to-list/app.py | 6 +++++ exercises/02-Loop-list/app.py | 3 ++- exercises/02.1-Loop-from-the-top/app.py | 3 ++- exercises/02.2-Loop-adding-two/app.py | 2 +- .../02.3-loop-from-the-half-to-the-end/app.py | 9 ++++--- exercises/02.4-One_last_looping/app.py | 7 +++++ exercises/02.5-Finding_wally/app.py | 13 ++++++++++ exercises/03-flip_list/app.py | 12 +++++++++ exercises/04-mixed_list/app.py | 10 +++++++ exercises/04.1-count_on/app.py | 12 +++++++++ exercises/05-Sum_all_items/app.py | 17 +++++++++--- exercises/05.1-sum_odd_items/app.py | 9 +++++++ exercises/06-Print_by_condition/app.py | 5 +++- exercises/06.1-Everything_is_awesome/app.py | 8 +++--- exercises/07-Do_while/app.py | 8 ++++++ exercises/08-Delete_element/app.py | 6 ++++- exercises/08.1-Merge_list/app.py | 9 ++++++- exercises/08.2-Divide_and_conquer/app.py | 10 +++++++ exercises/09-Max_integer_from_list/app.py | 8 ++++++ exercises/09.1-For_loop_min_value/app.py | 5 ++++ exercises/10-Find_avg/app.py | 5 ++++ .../10.1-And_One_and_a_Two_and_a_Three/app.py | 3 +++ exercises/11-Nested_list/app.py | 9 +++++++ exercises/12-Map_a_list/app.py | 11 +++++--- exercises/12.1-more_mapping/app.py | 6 ++++- .../12.2-Map_function_inside_variable/app.py | 2 ++ exercises/12.3-Map_data_types/app.py | 5 ++-- exercises/12.4-Map_list_of_objects/app.py | 10 +++---- exercises/12.5-Yes_and_no/app.py | 8 ++++++ exercises/12.6-Transformers/app.py | 5 ++++ exercises/13-Filter_list/app.py | 3 ++- exercises/13.1-Filter_and_list/app.py | 4 +++ exercises/13.2-filter_done_tasks/app.py | 6 +++++ exercises/13.3-Filter_list_strings/app.py | 5 ++++ .../app.py | 26 ++++++++++++++----- exercises/14-Loop-dictionary/app.py | 3 +++ exercises/14.1-letter_counter/app.py | 9 +++++++ exercises/15.1-Matrix_Builder/app.py | 11 ++++++++ exercises/15.2-Parking_lot_check/app.py | 24 +++++++++++++++++ exercises/16-Techno_beat/app.py | 17 ++++++++++++ 45 files changed, 310 insertions(+), 38 deletions(-) diff --git a/exercises/01-hello-world/app.py b/exercises/01-hello-world/app.py index fce62c1d..0ec004ea 100644 --- a/exercises/01-hello-world/app.py +++ b/exercises/01-hello-world/app.py @@ -1 +1,2 @@ # Your code here +print("Hello World") diff --git a/exercises/01.1-Access-and-Retrieve/app.py b/exercises/01.1-Access-and-Retrieve/app.py index 250261b7..5dcff67d 100644 --- a/exercises/01.1-Access-and-Retrieve/app.py +++ b/exercises/01.1-Access-and-Retrieve/app.py @@ -1,7 +1,11 @@ my_list = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'] # 1. Print the 3rd item here +print(my_list[2]) # 2. Change the value of 'thursday' to None +my_list[4] = None # 3. Print that position now here +position = my_list.index(None) +print(my_list[4]) diff --git a/exercises/01.2-Retrieve-items/app.py b/exercises/01.2-Retrieve-items/app.py index 9208b3cd..b6ceb08c 100644 --- a/exercises/01.2-Retrieve-items/app.py +++ b/exercises/01.2-Retrieve-items/app.py @@ -1,5 +1,7 @@ my_list = [4,5,734,43,45,100,4,56,23,67,23,58,45,3,100,4,56,23] # Print in the console the 1st element on the list +print(my_list[0]) # Print in the console the 4th element on the list +print(my_list[3]) diff --git a/exercises/01.3-Print-the-last-one/app.py b/exercises/01.3-Print-the-last-one/app.py index 68fa5b25..bdafd108 100644 --- a/exercises/01.3-Print-the-last-one/app.py +++ b/exercises/01.3-Print-the-last-one/app.py @@ -4,7 +4,6 @@ def generate_random_list(): aux_list = [] randonlength = random.randint(1, 100) - for i in range(randonlength): aux_list.append(randonlength) i += i @@ -13,4 +12,6 @@ def generate_random_list(): my_stupid_list = generate_random_list() # Write your code below this comment, good luck! - +the_last_one = my_stupid_list[-1] +print(the_last_one) +print(my_stupid_list) diff --git a/exercises/01.4-loop-seventeen/app.py b/exercises/01.4-loop-seventeen/app.py index 0bdc85b5..5985826a 100644 --- a/exercises/01.4-loop-seventeen/app.py +++ b/exercises/01.4-loop-seventeen/app.py @@ -1 +1,3 @@ # Your code here, have fun: +for i in range(1,18): + print(i) \ No newline at end of file diff --git a/exercises/01.5-Add-item-to-list/app.py b/exercises/01.5-Add-item-to-list/app.py index c74ded5f..5aded267 100644 --- a/exercises/01.5-Add-item-to-list/app.py +++ b/exercises/01.5-Add-item-to-list/app.py @@ -1,5 +1,11 @@ # Remember to import random function here +import random my_list = [4, 5, 734, 43, 45] # The magic goes below +print(my_list) +for i in range(1,11): + my_list.append(random.randint(101,201)) + i+=1 +print(my_list) diff --git a/exercises/02-Loop-list/app.py b/exercises/02-Loop-list/app.py index 13b3228b..31ac420c 100644 --- a/exercises/02-Loop-list/app.py +++ b/exercises/02-Loop-list/app.py @@ -1,4 +1,5 @@ my_list = [232,32,1,4,55,4,3,32,3,24,5,5,5,34,2,35,5365743,52,34,3,55] # Your code here -print(my_list[0]) +for x , item in enumerate(my_list): + print(item) diff --git a/exercises/02.1-Loop-from-the-top/app.py b/exercises/02.1-Loop-from-the-top/app.py index 1442ea68..fccc9fff 100644 --- a/exercises/02.1-Loop-from-the-top/app.py +++ b/exercises/02.1-Loop-from-the-top/app.py @@ -2,5 +2,6 @@ # Modify the loop below to print from end to start -for i in range(0, len(my_sample_list)): +for i in range(len(my_sample_list)-1,-1,-1) : print(my_sample_list[i]) + diff --git a/exercises/02.2-Loop-adding-two/app.py b/exercises/02.2-Loop-adding-two/app.py index 2a2a5f60..54240ae1 100644 --- a/exercises/02.2-Loop-adding-two/app.py +++ b/exercises/02.2-Loop-adding-two/app.py @@ -2,6 +2,6 @@ # Your code below, don't change anything above -for i in range(0, len(my_sample_list), 1): +for i in range(0, len(my_sample_list), 2): print(my_sample_list[i]) diff --git a/exercises/02.3-loop-from-the-half-to-the-end/app.py b/exercises/02.3-loop-from-the-half-to-the-end/app.py index a2cf3175..8961379d 100644 --- a/exercises/02.3-loop-from-the-half-to-the-end/app.py +++ b/exercises/02.3-loop-from-the-half-to-the-end/app.py @@ -1,9 +1,12 @@ +from math import ceil + my_list = [3423,5,4,47889,654,8,867543,23,48,56432,55,23,25,12] # Your code here -inicial_value = 0 -stop_value = 0 -increase_value = 0 + +inicial_value = ceil(len(my_list)/2) +stop_value = len(my_list) +increase_value = 1 for i in range(inicial_value, stop_value, increase_value): print(my_list[i]) diff --git a/exercises/02.4-One_last_looping/app.py b/exercises/02.4-One_last_looping/app.py index 0607676f..4bd036ef 100644 --- a/exercises/02.4-One_last_looping/app.py +++ b/exercises/02.4-One_last_looping/app.py @@ -1,3 +1,10 @@ names = ['Esmeralda','Kiko','Ruth','Lebron','Pedro','Maria','Lou','Fernando','Cesco','Bart','Annie'] # Your code here +names[1]="Steven" +arrLen = len(names) +names[arrLen-1] ="Pepe" +names[0]=names[2] + names[4] + +for x in range(arrLen-1,-2,-1): + print(names[x]) \ No newline at end of file diff --git a/exercises/02.5-Finding_wally/app.py b/exercises/02.5-Finding_wally/app.py index 44797d49..ed8f2e3c 100644 --- a/exercises/02.5-Finding_wally/app.py +++ b/exercises/02.5-Finding_wally/app.py @@ -1,3 +1,16 @@ people = ['Lebron','Aaliyah','Diamond','Dominique','Aliyah','Jazmin','Darnell','Hatfield','Hawkins','Hayden','Hayes','Haynes','Hays','Head','Heath','Hebert','Henderson','Hendricks','Hendrix','Henry','Hensley','Henson','Herman','Hernandez','Herrera','Herring','Hess','Hester','Hewitt','Hickman','Hicks','Higgins','Hill','Hines','Hinton','Hobbs','Hodge','Hodges','Hoffman','Hogan','Holcomb','Holden','Holder','Holland','Holloway','Holman','Holmes','Holt','Hood','Hooper','Hoover','Hopkins','Hopper','Horn','Horne','Horton','House','Houston','Howard','Howe','Howell','Hubbard','Huber','Hudson','Huff','Wally','Hughes','Hull','Humphrey','Hunt','Hunter','Hurley','Hurst','Hutchinson','Hyde','Ingram','Irwin','Jackson','Jacobs','Jacobson','James','Jarvis','Jefferson','Jenkins','Jennings','Jensen','Jimenez','Johns','Johnson','Johnston','Jones','Jordan','Joseph','Joyce','Joyner','Juarez','Justice','Kane','Kaufman','Keith','Keller','Kelley','Kelly','Kemp','Kennedy','Kent','Kerr','Key','Kidd','Kim','King','Kinney','Kirby','Kirk','Kirkland','Klein','Kline','Knapp','Knight','Knowles','Knox','Koch','Kramer','Lamb','Lambert','Lancaster','Landry','Lane','Lang','Langley','Lara','Larsen','Larson','Lawrence','Lawson','Le','Leach','Leblanc','Lee','Leon','Leonard','Lester','Levine','Levy','Lewis','Lindsay','Lindsey','Little','Livingston','Lloyd','Logan','Long','Lopez','Lott','Love','Lowe','Lowery','Lucas','Luna','Lynch','Lynn','Lyons','Macdonald','Macias','Mack','Madden','Maddox','Maldonado','Malone','Mann','Manning','Marks','Marquez','Marsh','Marshall','Martin','Martinez','Mason','Massey','Mathews','Mathis','Matthews','Maxwell','May','Mayer','Maynard','Mayo','Mays','Mcbride','Mccall','Mccarthy','Mccarty','Mcclain','Mcclure','Mcconnell','Mccormick','Mccoy','Mccray','Wally','Mcdaniel','Mcdonald','Mcdowell','Mcfadden','Mcfarland','Mcgee','Mcgowan','Mcguire','Mcintosh','Mcintyre','Mckay','Mckee','Mckenzie','Mckinney','Mcknight','Mclaughlin','Mclean','Mcleod','Mcmahon','Mcmillan','Mcneil','Mcpherson','Meadows','Medina','Mejia','Melendez','Melton','Mendez','Mendoza','Mercado','Mercer','Merrill','Merritt','Meyer','Meyers','Michael','Middleton','Miles','Miller','Mills','Miranda','Mitchell','Molina','Monroe','Lucas','Jake','Scott','Amy','Molly','Hannah','Lucas'] # Your code here +wallys_position = people.index("Wally") +print("Wally is in position:", wallys_position) + +wallys_position =-100 +# Alternatively, to find all occurrences of "Wally": +# wallys_position = [i for i , list_item in enumerate(people) if list_item == "Wally"] +# print("Wally is in position:", wallys_position) + +wallys_position = (index for index, name in enumerate(people) if name == "Wally") +# print(list(wallys_position)) + +for x in wallys_position: + print(x) diff --git a/exercises/03-flip_list/app.py b/exercises/03-flip_list/app.py index d2f3e18b..eea4de69 100644 --- a/exercises/03-flip_list/app.py +++ b/exercises/03-flip_list/app.py @@ -1,3 +1,15 @@ sample_list = [45, 67, 87, 23, 5, 32, 60] # Your code below +new_list= [] + +# new_list =sample_list.reverse() +# print(sample_list) + +# for index, item in enumerate(sample_list): +# new_list[index]=item +new_list_index = 0 +for i in range(len(sample_list)-1,-1,-1): + new_list.insert(new_list_index,sample_list[i]) + new_list_index +=1 +print (new_list) \ No newline at end of file diff --git a/exercises/04-mixed_list/app.py b/exercises/04-mixed_list/app.py index 3aab4234..47a5801e 100644 --- a/exercises/04-mixed_list/app.py +++ b/exercises/04-mixed_list/app.py @@ -1,3 +1,13 @@ mix = [42, True, "towel", [2,1], 'hello', 34.4, {"name": "juan"}] # Your code below +def getTypeOfElements(myList): + + for i in range(0,len(myList),1): + myList[i] = type(myList[i]) + return myList + +newArr = getTypeOfElements(mix) + +for x in newArr: + print(x) diff --git a/exercises/04.1-count_on/app.py b/exercises/04.1-count_on/app.py index c02ec494..bbdbadde 100644 --- a/exercises/04.1-count_on/app.py +++ b/exercises/04.1-count_on/app.py @@ -1,3 +1,15 @@ my_list = [42, True, "towel", [2,1], 'hello', 34.4, {"name": "juan"}] # Your code here +new_list = [] +# for i , item in enumerate(my_list): +# if(type(item) == list or type(item) == dict): +# new_list.append(item) +# for i in range(0,len(my_list),1): +# if (type(my_list[i]) ==list or type(my_list[i]) == dict): +# new_list.append(my_list[i]) + +for i in range(0,len(my_list),1): + if (isinstance(my_list[i],(list,dict))): + new_list.append(my_list[i]) +print(new_list) \ No newline at end of file diff --git a/exercises/05-Sum_all_items/app.py b/exercises/05-Sum_all_items/app.py index 26582cb2..42f17f82 100644 --- a/exercises/05-Sum_all_items/app.py +++ b/exercises/05-Sum_all_items/app.py @@ -1,10 +1,21 @@ +from functools import reduce + my_sample_list = [3423,5,4,47889,654,8,867543,23,48,5345,234,6,78,54,23,67,3,6,432,55,23,25,12] -def sum_all_values(list): +def sum_all_values(my_sample_list): total = 0 # The magic happens here - - + # use of builtin function sum + # total = sum(my_sample_list) + # print(total) + # total=0 + # use of reduce and lambda function + # total = reduce(lambda x,y: x+y,my_sample_list) + # print(total) + # total=0 + # use of for loop + for item in my_sample_list: + total += item return total print(sum_all_values(my_sample_list)) diff --git a/exercises/05.1-sum_odd_items/app.py b/exercises/05.1-sum_odd_items/app.py index c6f86a84..6aee04a8 100644 --- a/exercises/05.1-sum_odd_items/app.py +++ b/exercises/05.1-sum_odd_items/app.py @@ -1,3 +1,12 @@ my_list = [4,5,734,43,45,100,4,56,23,67,23,58,45] # Your code here + +def sum_odds(my_list): + total=0 + for item in my_list: + if item%2 !=0 : + total += item + return total + +print(sum_odds(my_list)) \ No newline at end of file diff --git a/exercises/06-Print_by_condition/app.py b/exercises/06-Print_by_condition/app.py index de6e8f61..9dc6cdd1 100644 --- a/exercises/06-Print_by_condition/app.py +++ b/exercises/06-Print_by_condition/app.py @@ -1,6 +1,9 @@ my_list = [3344,34334,454543,342534,4563456,3445,23455,234,262,2335,43323,4356,345,4545,452,345,434,36,345,4334,5454,345,4352,23,365,345,47,63,425,6578759,768,834,754,35,32,445,453456,56,7536867,3884526,4234,35353245,53244523,566785,7547,743,4324,523472634,26665,63432,54645,32,453625,7568,5669576,754,64356,542644,35,243,371,3251,351223,13231243,734,856,56,53,234342,56,545343] -for i in my_list: +for item in my_list: # The magic happens here + if item % 14 == 0: + print(item) + diff --git a/exercises/06.1-Everything_is_awesome/app.py b/exercises/06.1-Everything_is_awesome/app.py index 4c3d0c26..061dac73 100644 --- a/exercises/06.1-Everything_is_awesome/app.py +++ b/exercises/06.1-Everything_is_awesome/app.py @@ -2,10 +2,12 @@ def my_function(numbers): new_list = [] - for i in numbers: + for num in numbers: # The magic happens here - - + if num == 1: + new_list.append(num) + else: + new_list.append("Yahoo") return new_list print(my_function(my_list)) diff --git a/exercises/07-Do_while/app.py b/exercises/07-Do_while/app.py index fce62c1d..5a9c9433 100644 --- a/exercises/07-Do_while/app.py +++ b/exercises/07-Do_while/app.py @@ -1 +1,9 @@ # Your code here +x = 20 +while x > 0 : + if x % 5 == 0: + print(str(x) +"!") + else: + print(x) + x -= 1 +print("LIFTOFF") diff --git a/exercises/08-Delete_element/app.py b/exercises/08-Delete_element/app.py index 36514c4d..f658f751 100644 --- a/exercises/08-Delete_element/app.py +++ b/exercises/08-Delete_element/app.py @@ -2,7 +2,11 @@ def delete_person(person_name): # Your code here - + new_people = [] + for person in people: + if person != person_name : + new_people.append(person) + return new_people # Don't delete anything below diff --git a/exercises/08.1-Merge_list/app.py b/exercises/08.1-Merge_list/app.py index 6146f098..b1a0e356 100644 --- a/exercises/08.1-Merge_list/app.py +++ b/exercises/08.1-Merge_list/app.py @@ -4,6 +4,13 @@ def merge_list(list1, list2): # Your code here - + merged_list = [] + # same as "spread operator '...' in JavaScript" + # here we use '*' to unpack the lists and tuples, and use '**' to unpack dictionaries + # merged_list = [*list1,*list2] + merged_list = [*list1] + for item in list2: + merged_list.append(item) + return merged_list print(merge_list(chunk_one, chunk_two)) diff --git a/exercises/08.2-Divide_and_conquer/app.py b/exercises/08.2-Divide_and_conquer/app.py index 106fd02b..629cd2b2 100644 --- a/exercises/08.2-Divide_and_conquer/app.py +++ b/exercises/08.2-Divide_and_conquer/app.py @@ -1,7 +1,17 @@ list_of_numbers = [4, 80, 85, 59, 37, 25, 5, 64, 66, 81, 20, 64, 41, 22, 76, 76, 55, 96, 2, 68] # Your code here +def sort_odd_even(list1): + even = [] + odd = [] + for item in list1: + if item %2 == 0: + even.append(item) + else: + odd.append(item) + odd.extend(even) + return odd print(sort_odd_even(list_of_numbers)) diff --git a/exercises/09-Max_integer_from_list/app.py b/exercises/09-Max_integer_from_list/app.py index c0a5a543..9077b1d1 100644 --- a/exercises/09-Max_integer_from_list/app.py +++ b/exercises/09-Max_integer_from_list/app.py @@ -1,3 +1,11 @@ my_list = [43,23,6,87,43,1,4,6,3,67,8,3445,3,7,5435,63,346,3,456,734,6,34] # Your code here + +def max_integer(mylist): + max_num = 0 + for num in mylist: + if num > max_num: + max_num = num + return max_num +print(max_integer(my_list)) \ No newline at end of file diff --git a/exercises/09.1-For_loop_min_value/app.py b/exercises/09.1-For_loop_min_value/app.py index 594b1d3d..a968166d 100644 --- a/exercises/09.1-For_loop_min_value/app.py +++ b/exercises/09.1-For_loop_min_value/app.py @@ -1,3 +1,8 @@ my_list = [3344,34334,454543,342534,4563456,3445,23455,234,262,2335,43323,4356,345,4545,452,345,434,36,345,4334,5454,345,4352,23,365,345,47,63,425,6578759,768,834,754,35,32,445,453456,56,7536867,3884526,4234,35353245,53244523,566785,7547,743,4324,523472634,26665,63432,54645,32,453625,7568,5669576,754,64356,542644,35,243,371,3251,351223,13231243,734,856,56,53,234342,56,545343] # Your code here +min_value = my_list[0] +for num in my_list: + if num < min_value: + min_value = num +print(min_value) \ No newline at end of file diff --git a/exercises/10-Find_avg/app.py b/exercises/10-Find_avg/app.py index c881b318..b380378b 100644 --- a/exercises/10-Find_avg/app.py +++ b/exercises/10-Find_avg/app.py @@ -1,3 +1,8 @@ my_list = [2323,4344,2325,324413,21234,24531,2123,42234,544,456,345,42,5445,23,5656,423] # Your code here +total = 0 +for item in my_list: + total += item +avg_val = total/len(my_list) +print(avg_val) diff --git a/exercises/10.1-And_One_and_a_Two_and_a_Three/app.py b/exercises/10.1-And_One_and_a_Two_and_a_Three/app.py index 54e60221..d15ad3cb 100644 --- a/exercises/10.1-And_One_and_a_Two_and_a_Three/app.py +++ b/exercises/10.1-And_One_and_a_Two_and_a_Three/app.py @@ -5,4 +5,7 @@ } # Your code here +for key, value in contact.items(): + print(key+": "+ value) + diff --git a/exercises/11-Nested_list/app.py b/exercises/11-Nested_list/app.py index c08ecc4a..9c0dab21 100644 --- a/exercises/11-Nested_list/app.py +++ b/exercises/11-Nested_list/app.py @@ -1,3 +1,12 @@ coordinates_list = [[33.747252, -112.633853], [-33.867886, -63.987], [41.303921, -81.901693], [-33.350534, -71.653268]] # Your code here +for i in range(0,len(coordinates_list)): + print(coordinates_list[i][1]) + + + + + + + diff --git a/exercises/12-Map_a_list/app.py b/exercises/12-Map_a_list/app.py index bbaa6e5d..5309788d 100644 --- a/exercises/12-Map_a_list/app.py +++ b/exercises/12-Map_a_list/app.py @@ -1,9 +1,12 @@ celsius_values = [-2, 34, 56, -10] def celsius_to_fahrenheit(celsius): - # The magic happens here - + # The magic happens here + fahrenheit_values = [(celsius * 9/5) + 32 for celsius in celsius_values] + return fahrenheit_values -result = list(map(celsius_to_fahrenheit, celsius_values)) -print(result) + + +result = list(map(celsius_to_fahrenheit, celsius_values)) +print(celsius_to_fahrenheit(celsius_values)) diff --git a/exercises/12.1-more_mapping/app.py b/exercises/12.1-more_mapping/app.py index c5d1ca14..5bcbfc04 100644 --- a/exercises/12.1-more_mapping/app.py +++ b/exercises/12.1-more_mapping/app.py @@ -1,5 +1,9 @@ my_numbers = [23,234,345,4356234,243,43,56,2] # Your code here +def multiply_by_three(num): + newNum = num * 3 + return newNum -print(new_list) +new_list = list(map(multiply_by_three,my_numbers)) +print(new_list) \ No newline at end of file diff --git a/exercises/12.2-Map_function_inside_variable/app.py b/exercises/12.2-Map_function_inside_variable/app.py index 7146df37..d3ce1ad5 100644 --- a/exercises/12.2-Map_function_inside_variable/app.py +++ b/exercises/12.2-Map_function_inside_variable/app.py @@ -4,3 +4,5 @@ def prepender(name): return "My name is: " + name # Your code here +test_list = list(map(prepender, names)) +print(test_list) diff --git a/exercises/12.3-Map_data_types/app.py b/exercises/12.3-Map_data_types/app.py index c1225967..522bfbe0 100644 --- a/exercises/12.3-Map_data_types/app.py +++ b/exercises/12.3-Map_data_types/app.py @@ -1,9 +1,8 @@ mixed_list = ['1','5','45','34','343','34',6556,323] def type_list(items): - # Your code here - return + items = type(items) + return items new_list = list(map(type_list, mixed_list)) - print(new_list) diff --git a/exercises/12.4-Map_list_of_objects/app.py b/exercises/12.4-Map_list_of_objects/app.py index de3e0d1f..d8a5f696 100644 --- a/exercises/12.4-Map_list_of_objects/app.py +++ b/exercises/12.4-Map_list_of_objects/app.py @@ -15,9 +15,9 @@ def calculate_age(date_of_birth): def format_greeting(person): # Your code here - return person["name"] + dob = person["birth_date"].date() + age = calculate_age(dob) + return f'Hello, my name is {person["name"]} and I am {age} years old' - -name_list = list(map(format_greeting, people)) - -print(name_list) +greetings = list(map(format_greeting,people)) +print(greetings) diff --git a/exercises/12.5-Yes_and_no/app.py b/exercises/12.5-Yes_and_no/app.py index bdbe9f38..32605887 100644 --- a/exercises/12.5-Yes_and_no/app.py +++ b/exercises/12.5-Yes_and_no/app.py @@ -1,4 +1,12 @@ 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] # Your code here +def wiki_woko(the_bit): + if the_bit ==1 : + return "wiki" + else: + return "woko" + +new_list = list(map(wiki_woko,the_bools)) +print(new_list) diff --git a/exercises/12.6-Transformers/app.py b/exercises/12.6-Transformers/app.py index cb949489..71e4146b 100644 --- a/exercises/12.6-Transformers/app.py +++ b/exercises/12.6-Transformers/app.py @@ -7,4 +7,9 @@ ] # Your code here +def data_transformer(ajax_data): + return f"{ajax_data['name']} {ajax_data['last_name']}" + +transformed_data = list(map(data_transformer, incoming_ajax_data)) +print(transformed_data) \ No newline at end of file diff --git a/exercises/13-Filter_list/app.py b/exercises/13-Filter_list/app.py index 0f91fe6c..3a9505ef 100644 --- a/exercises/13-Filter_list/app.py +++ b/exercises/13-Filter_list/app.py @@ -3,7 +3,8 @@ def filter_function(item): # Update here - return item % 2 == 1 + if item > 10: + return item greater_than_ten = list(filter(filter_function, all_numbers)) diff --git a/exercises/13.1-Filter_and_list/app.py b/exercises/13.1-Filter_and_list/app.py index b9e376e0..ba862eec 100644 --- a/exercises/13.1-Filter_and_list/app.py +++ b/exercises/13.1-Filter_and_list/app.py @@ -1,7 +1,11 @@ all_names = ["Romario", "Boby", "Roosevelt", "Emiliy", "Michael", "Greta", "Patricia", "Danzalee"] # Your code here +def filter_R_names(name): + if name.startswith("R",0): + return name +resulting_names = list(filter(filter_R_names,all_names)) print(resulting_names) diff --git a/exercises/13.2-filter_done_tasks/app.py b/exercises/13.2-filter_done_tasks/app.py index 2a69b63f..269aaba1 100644 --- a/exercises/13.2-filter_done_tasks/app.py +++ b/exercises/13.2-filter_done_tasks/app.py @@ -11,4 +11,10 @@ # Your code here +def getfinishedTasksOnly(task): + if task["done"] == True : + return task + +finishedTasks = list(filter(getfinishedTasksOnly,tasks)) +print(finishedTasks) diff --git a/exercises/13.3-Filter_list_strings/app.py b/exercises/13.3-Filter_list_strings/app.py index af96ba6c..301f54d7 100644 --- a/exercises/13.3-Filter_list_strings/app.py +++ b/exercises/13.3-Filter_list_strings/app.py @@ -1,3 +1,8 @@ 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'] # Your code here +def findNamesWith_am(name): + return"am" in name.lower() + +new_names = list(filter(findNamesWith_am,names)) +print(new_names) diff --git a/exercises/13.4-Making_HTML_with_filter_and_maP/app.py b/exercises/13.4-Making_HTML_with_filter_and_maP/app.py index 979857d7..a424786a 100644 --- a/exercises/13.4-Making_HTML_with_filter_and_maP/app.py +++ b/exercises/13.4-Making_HTML_with_filter_and_maP/app.py @@ -1,12 +1,24 @@ all_colors = [ - {"label": 'Red', "sexy": True}, - {"label": 'Pink', "sexy": False}, - {"label": 'Orange', "sexy": True}, - {"label": 'Brown', "sexy": False}, - {"label": 'Pink', "sexy": True}, - {"label": 'Violet', "sexy": True}, - {"label": 'Purple', "sexy": False}, + {"label": 'Red', "sexy": True}, + {"label": 'Pink', "sexy": False}, + {"label": 'Orange', "sexy": True}, + {"label": 'Brown', "sexy": False}, + {"label": 'Pink', "sexy": True}, + {"label": 'Violet', "sexy": True}, + {"label": 'Purple', "sexy": False}, ] # Your code here +def generate_li(item_color): + return f"
  • {item_color['label']}
  • " +def filter_colors(all_colors): + return filter(lambda color:color["sexy"], all_colors) + + +filteredColors = filter_colors(all_colors) +# print(filteredColors) + + +htmlLi = list(map(generate_li,filteredColors)) +print(htmlLi) \ No newline at end of file diff --git a/exercises/14-Loop-dictionary/app.py b/exercises/14-Loop-dictionary/app.py index 8903bfb0..9d81c50c 100644 --- a/exercises/14-Loop-dictionary/app.py +++ b/exercises/14-Loop-dictionary/app.py @@ -1,5 +1,8 @@ spanish_translations = { "dog": "perro", "house": "casa", "cat": "gato" } # Your code here +spanish_translations["love"] = "amor" +spanish_translations["code"] = "codigo" +spanish_translations["smart"] = "inteligente" # Don't touch the code below diff --git a/exercises/14.1-letter_counter/app.py b/exercises/14.1-letter_counter/app.py index f4708592..efdaca69 100644 --- a/exercises/14.1-letter_counter/app.py +++ b/exercises/14.1-letter_counter/app.py @@ -4,5 +4,14 @@ # Your code here +for charac in par : + charac = charac.lower() + if charac == ' ': + continue + if charac in counts: + counts[charac] += 1 + else: + counts[charac] = 1 + print(counts) diff --git a/exercises/15.1-Matrix_Builder/app.py b/exercises/15.1-Matrix_Builder/app.py index fce62c1d..80b505e9 100644 --- a/exercises/15.1-Matrix_Builder/app.py +++ b/exercises/15.1-Matrix_Builder/app.py @@ -1 +1,12 @@ # Your code here +def matrix_builder(rowsAndCols): + newMatrix = [] + for i in range(0,rowsAndCols, 1): + row = [] + for j in range(0, rowsAndCols, 1): + row.append(1) + newMatrix.append(row) + return newMatrix + +print(matrix_builder(3)) + diff --git a/exercises/15.2-Parking_lot_check/app.py b/exercises/15.2-Parking_lot_check/app.py index e6f445f8..3dd1df42 100644 --- a/exercises/15.2-Parking_lot_check/app.py +++ b/exercises/15.2-Parking_lot_check/app.py @@ -5,3 +5,27 @@ ] # Your code here + +# parkinglot_dict = { +# "total_slots":0, +# "available_slots":0, +# "occupied_slots":0 +# } + +def get_parking_lot(parking_state): + parkinglotStatus = { + "total_slots":0, + "available_slots":0, + "occupied_slots":0 + } + for row in parking_state: + for col in row: + if col == 1: + parkinglotStatus["occupied_slots"] += 1 + elif col == 2: + parkinglotStatus["available_slots"] += 1 + parkinglotStatus["total_slots"] = parkinglotStatus["occupied_slots"] + parkinglotStatus["available_slots"] + return parkinglotStatus + +print(get_parking_lot(parking_state)) + diff --git a/exercises/16-Techno_beat/app.py b/exercises/16-Techno_beat/app.py index 5442b529..de67300f 100644 --- a/exercises/16-Techno_beat/app.py +++ b/exercises/16-Techno_beat/app.py @@ -1,4 +1,21 @@ +def lyrics_generator(list1): + + lyricStr ="" + countOnes = 0 + + for item in list1: + if item==0: + lyricStr += "Boom " + countOnes = 0 + else: + lyricStr +="Drop the bass " + countOnes +=1 + if countOnes ==3: + lyricStr += "!!!Break the bass!!! " + countOnes = 0 + return lyricStr + # Your code above, nothing to change after this line print(lyrics_generator([0,0,1,1,0,0,0]))