diff --git a/.learn/resets/001-hello_world/app.py b/.learn/resets/001-hello_world/app.py new file mode 100644 index 00000000..fce62c1d --- /dev/null +++ b/.learn/resets/001-hello_world/app.py @@ -0,0 +1 @@ +# Your code here diff --git a/.learn/resets/002-sum_of_three_numbers/app.py b/.learn/resets/002-sum_of_three_numbers/app.py new file mode 100644 index 00000000..21d0f403 --- /dev/null +++ b/.learn/resets/002-sum_of_three_numbers/app.py @@ -0,0 +1,8 @@ +# Sum all three input numbers and print on the console the result +first_number = int(input("First input: ")) +second_number = int(input("Second input: ")) +third_number = int(input("Third input: ")) + + +# Print here the sum of all three inputs +print(first_number+second_number) diff --git a/.learn/resets/003-area_of_right_triangle/app.py b/.learn/resets/003-area_of_right_triangle/app.py new file mode 100644 index 00000000..6b4bb318 --- /dev/null +++ b/.learn/resets/003-area_of_right_triangle/app.py @@ -0,0 +1,7 @@ +# Complete the function to return the area of a triangle +def area_of_triangle(base, height): + # Your code here, please remove the "None" + return None + +# Testing your function +print(area_of_triangle(3, 5)) diff --git a/.learn/resets/004-hello_harry/app.py b/.learn/resets/004-hello_harry/app.py new file mode 100644 index 00000000..4d3f3e24 --- /dev/null +++ b/.learn/resets/004-hello_harry/app.py @@ -0,0 +1,7 @@ +# Complete the function below to print the output as per the example +def hello_name(name): + # Your code here + return None + +# Invoke the function with your name as the function's argument +print(hello_name("Bob")) diff --git a/.learn/resets/005-previous_and_next/app.py b/.learn/resets/005-previous_and_next/app.py new file mode 100644 index 00000000..d549fb0d --- /dev/null +++ b/.learn/resets/005-previous_and_next/app.py @@ -0,0 +1,8 @@ +# Complete the function to return the previous and next number of a given number +def previous_next(num): + # Your code here + return None + + +# Invoke the function with any integer as its argument +print(previous_next(179)) diff --git a/.learn/resets/006-apple_sharing/app.py b/.learn/resets/006-apple_sharing/app.py new file mode 100644 index 00000000..2c17d877 --- /dev/null +++ b/.learn/resets/006-apple_sharing/app.py @@ -0,0 +1,6 @@ +def apple_sharing(n,k): + # Your code here + return None + + +print(apple_sharing(6,50)) diff --git a/.learn/resets/006.1-square_value_of_number/app.py b/.learn/resets/006.1-square_value_of_number/app.py new file mode 100644 index 00000000..086d1e41 --- /dev/null +++ b/.learn/resets/006.1-square_value_of_number/app.py @@ -0,0 +1,5 @@ +def square(num): + # Your code here + return None + +print(square(6)) diff --git a/.learn/resets/007-hours_and_minutes/app.py b/.learn/resets/007-hours_and_minutes/app.py new file mode 100644 index 00000000..14ce499b --- /dev/null +++ b/.learn/resets/007-hours_and_minutes/app.py @@ -0,0 +1,6 @@ +def hours_minutes(seconds): + # Your code here + return None + +# Invoke the function and pass any integer as its argument +print(hours_minutes(3900)) diff --git a/.learn/resets/008-two_timestamps/app.py b/.learn/resets/008-two_timestamps/app.py new file mode 100644 index 00000000..ab47d89d --- /dev/null +++ b/.learn/resets/008-two_timestamps/app.py @@ -0,0 +1,7 @@ +def two_timestamp(hr1, min1, sec1, hr2, min2, sec2): + # Your code here + return None + + +# Invoke the function and pass two timestamps(6 intergers) as its arguments +print(two_timestamp(1,1,1,2,2,2)) diff --git a/.learn/resets/009-two_digits/app.py b/.learn/resets/009-two_digits/app.py new file mode 100644 index 00000000..a8a424e7 --- /dev/null +++ b/.learn/resets/009-two_digits/app.py @@ -0,0 +1,8 @@ +# Complete the function to return the tens digit and the units digit of any interger +def two_digits(number): + # Your code here + return None + + +# Invoke the function with any two digit integer as its argument +print(two_digits(79)) diff --git a/.learn/resets/010-swap_digits/app.py b/.learn/resets/010-swap_digits/app.py new file mode 100644 index 00000000..9fc7ba9a --- /dev/null +++ b/.learn/resets/010-swap_digits/app.py @@ -0,0 +1,7 @@ +# Complete the function to return the swapped digits of a given two-digit integer +def swap_digits(num): + # Your code here + return None + +# Invoke the function with any two-digit integer as its argument +print(swap_digits(30)) diff --git a/.learn/resets/011-last_two_digits/app.py b/.learn/resets/011-last_two_digits/app.py new file mode 100644 index 00000000..cf00ec28 --- /dev/null +++ b/.learn/resets/011-last_two_digits/app.py @@ -0,0 +1,6 @@ +# Complete the function to print the last two digits of an integer greater than 9 +def last_two_digits(num): + return None + +# Invoke the function with any integer greater than 9 +print(last_two_digits()) diff --git a/.learn/resets/012-tens_digit/app.py b/.learn/resets/012-tens_digit/app.py new file mode 100644 index 00000000..467c2902 --- /dev/null +++ b/.learn/resets/012-tens_digit/app.py @@ -0,0 +1,7 @@ +# Complete the function to return the tens digit of a given integer +def tens_digit(num): + return None + + +# Invoke the function with any integer +print(tens_digit()) diff --git a/.learn/resets/013-sum_of_digits/app.py b/.learn/resets/013-sum_of_digits/app.py new file mode 100644 index 00000000..502dff35 --- /dev/null +++ b/.learn/resets/013-sum_of_digits/app.py @@ -0,0 +1,7 @@ +# Complete the function "digits_sum" so that it prints the sum of a three-digit number +def digits_sum(num): + return None + + +# Invoke the function with any three-digit number +print(digits_sum(123)) diff --git a/.learn/resets/014-digit_after_decimal_point/app.py b/.learn/resets/014-digit_after_decimal_point/app.py new file mode 100644 index 00000000..01940696 --- /dev/null +++ b/.learn/resets/014-digit_after_decimal_point/app.py @@ -0,0 +1,7 @@ +# Complete the function to return the first digit to the right of the decimal point +def first_digit(num): + return None + + +# Invoke the function with a positive real number. ex. 34.33 +print(first_digit()) diff --git a/.learn/resets/015-car_route/app.py b/.learn/resets/015-car_route/app.py new file mode 100644 index 00000000..909df947 --- /dev/null +++ b/.learn/resets/015-car_route/app.py @@ -0,0 +1,7 @@ +# Complete the function to return the amount of days it will take to cover a route +def car_route(n,m): + return None + + +# Invoke the function with two integers +print(car_route()) diff --git a/.learn/resets/016-century/app.py b/.learn/resets/016-century/app.py new file mode 100644 index 00000000..54c39550 --- /dev/null +++ b/.learn/resets/016-century/app.py @@ -0,0 +1,7 @@ +# Complete the function to return the respective number of the century +def century(year): + return None + + +# Invoke the function with any given year +print(century()) diff --git a/.learn/resets/017-total_cost/app.py b/.learn/resets/017-total_cost/app.py new file mode 100644 index 00000000..cc578749 --- /dev/null +++ b/.learn/resets/017-total_cost/app.py @@ -0,0 +1,7 @@ +# Complete the function to return the total cost in dollars and cents of (n) cupcakes +def total_cost(d, c, n): + return None + + +# Invoke the function with three integers: total_cost(dollars, cents, number_of_cupcakes) +print(total_cost(15,22,4)) diff --git a/.learn/resets/018-day_of_week/app.py b/.learn/resets/018-day_of_week/app.py new file mode 100644 index 00000000..110ad973 --- /dev/null +++ b/.learn/resets/018-day_of_week/app.py @@ -0,0 +1,7 @@ +# Complete the function to return the number of day of the week for k'th day of year +def day_of_week(k): + return None + + +# Invoke function day_of_week with an integer between 1 and 365 +print(day_of_week()) diff --git a/.learn/resets/019-digital_clock/app.py b/.learn/resets/019-digital_clock/app.py new file mode 100644 index 00000000..1862864d --- /dev/null +++ b/.learn/resets/019-digital_clock/app.py @@ -0,0 +1,6 @@ +# Complete the function to return how many hours and minutes are displayed on the 24h digital clock +def digital_clock(n): + return None + +# Invoke the function with any integer (minutes after midnight) +print(digital_clock()) diff --git a/.learn/resets/020-factorial/app.py b/.learn/resets/020-factorial/app.py new file mode 100644 index 00000000..fce62c1d --- /dev/null +++ b/.learn/resets/020-factorial/app.py @@ -0,0 +1 @@ +# Your code here diff --git a/.learn/resets/021-square_root/app.py b/.learn/resets/021-square_root/app.py new file mode 100644 index 00000000..fce62c1d --- /dev/null +++ b/.learn/resets/021-square_root/app.py @@ -0,0 +1 @@ +# Your code here diff --git a/.learn/resets/022-Integral/app.py b/.learn/resets/022-Integral/app.py new file mode 100644 index 00000000..a51f0856 --- /dev/null +++ b/.learn/resets/022-Integral/app.py @@ -0,0 +1 @@ +# Your code here diff --git a/.learn/resets/023-list-and-tuple/app.py b/.learn/resets/023-list-and-tuple/app.py new file mode 100644 index 00000000..a51f0856 --- /dev/null +++ b/.learn/resets/023-list-and-tuple/app.py @@ -0,0 +1 @@ +# Your code here diff --git a/.learn/resets/024-class-with-two-methods/app.py b/.learn/resets/024-class-with-two-methods/app.py new file mode 100644 index 00000000..a51f0856 --- /dev/null +++ b/.learn/resets/024-class-with-two-methods/app.py @@ -0,0 +1 @@ +# Your code here diff --git a/.learn/resets/025-print-formula/app.py b/.learn/resets/025-print-formula/app.py new file mode 100644 index 00000000..a51f0856 --- /dev/null +++ b/.learn/resets/025-print-formula/app.py @@ -0,0 +1 @@ +# Your code here diff --git a/.learn/resets/026-two-dimensional-array/app.py b/.learn/resets/026-two-dimensional-array/app.py new file mode 100644 index 00000000..a51f0856 --- /dev/null +++ b/.learn/resets/026-two-dimensional-array/app.py @@ -0,0 +1 @@ +# Your code here diff --git a/.learn/resets/027-sequence-of-words/app.py b/.learn/resets/027-sequence-of-words/app.py new file mode 100644 index 00000000..a51f0856 --- /dev/null +++ b/.learn/resets/027-sequence-of-words/app.py @@ -0,0 +1 @@ +# Your code here diff --git a/.learn/resets/028-sequence-of-lines/app.py b/.learn/resets/028-sequence-of-lines/app.py new file mode 100644 index 00000000..a51f0856 --- /dev/null +++ b/.learn/resets/028-sequence-of-lines/app.py @@ -0,0 +1 @@ +# Your code here diff --git a/.learn/resets/029-remove-duplicate-words/app.py b/.learn/resets/029-remove-duplicate-words/app.py new file mode 100644 index 00000000..fce62c1d --- /dev/null +++ b/.learn/resets/029-remove-duplicate-words/app.py @@ -0,0 +1 @@ +# Your code here diff --git a/.learn/resets/030-divisable-binary/app.py b/.learn/resets/030-divisable-binary/app.py new file mode 100644 index 00000000..a51f0856 --- /dev/null +++ b/.learn/resets/030-divisable-binary/app.py @@ -0,0 +1 @@ +# Your code here diff --git a/.learn/resets/031-sum-eigth-digit/app.py b/.learn/resets/031-sum-eigth-digit/app.py new file mode 100644 index 00000000..a51f0856 --- /dev/null +++ b/.learn/resets/031-sum-eigth-digit/app.py @@ -0,0 +1 @@ +# Your code here diff --git a/.learn/resets/032-numbers-of-letters-and-digits/app.py b/.learn/resets/032-numbers-of-letters-and-digits/app.py new file mode 100644 index 00000000..a51f0856 --- /dev/null +++ b/.learn/resets/032-numbers-of-letters-and-digits/app.py @@ -0,0 +1 @@ +# Your code here diff --git a/.learn/resets/033-number-of-uppercase/app.py b/.learn/resets/033-number-of-uppercase/app.py new file mode 100644 index 00000000..a51f0856 --- /dev/null +++ b/.learn/resets/033-number-of-uppercase/app.py @@ -0,0 +1 @@ +# Your code here diff --git a/.learn/resets/034-a_aa_aaa_aaaa/app.py b/.learn/resets/034-a_aa_aaa_aaaa/app.py new file mode 100644 index 00000000..a51f0856 --- /dev/null +++ b/.learn/resets/034-a_aa_aaa_aaaa/app.py @@ -0,0 +1 @@ +# Your code here diff --git a/.learn/resets/035-square-each-odd-number/app.py b/.learn/resets/035-square-each-odd-number/app.py new file mode 100644 index 00000000..a51f0856 --- /dev/null +++ b/.learn/resets/035-square-each-odd-number/app.py @@ -0,0 +1 @@ +# Your code here diff --git a/.learn/resets/036-net-amount/app.py b/.learn/resets/036-net-amount/app.py new file mode 100644 index 00000000..a51f0856 --- /dev/null +++ b/.learn/resets/036-net-amount/app.py @@ -0,0 +1 @@ +# Your code here diff --git a/.learn/resets/037-validity-of-password/app.py b/.learn/resets/037-validity-of-password/app.py new file mode 100644 index 00000000..a51f0856 --- /dev/null +++ b/.learn/resets/037-validity-of-password/app.py @@ -0,0 +1 @@ +# Your code here diff --git a/exercises/001-hello_world/app.py b/exercises/001-hello_world/app.py index fce62c1d..a9b76882 100644 --- a/exercises/001-hello_world/app.py +++ b/exercises/001-hello_world/app.py @@ -1 +1,2 @@ # Your code here +print("Hello World") \ No newline at end of file diff --git a/exercises/002-sum_of_three_numbers/app.py b/exercises/002-sum_of_three_numbers/app.py index 21d0f403..ba0bd5fa 100644 --- a/exercises/002-sum_of_three_numbers/app.py +++ b/exercises/002-sum_of_three_numbers/app.py @@ -5,4 +5,4 @@ # Print here the sum of all three inputs -print(first_number+second_number) +print(first_number+second_number+third_number) diff --git a/exercises/003-area_of_right_triangle/app.py b/exercises/003-area_of_right_triangle/app.py index 6b4bb318..b03f37a3 100644 --- a/exercises/003-area_of_right_triangle/app.py +++ b/exercises/003-area_of_right_triangle/app.py @@ -1,7 +1,7 @@ # Complete the function to return the area of a triangle def area_of_triangle(base, height): # Your code here, please remove the "None" - return None + return (base*height)/2 # Testing your function print(area_of_triangle(3, 5)) diff --git a/exercises/004-hello_harry/app.py b/exercises/004-hello_harry/app.py index 4d3f3e24..a22375fe 100644 --- a/exercises/004-hello_harry/app.py +++ b/exercises/004-hello_harry/app.py @@ -1,7 +1,7 @@ # Complete the function below to print the output as per the example def hello_name(name): # Your code here - return None + return "Hello, " + name + "!" # Invoke the function with your name as the function's argument print(hello_name("Bob")) diff --git a/exercises/005-previous_and_next/app.py b/exercises/005-previous_and_next/app.py index d549fb0d..254f1074 100644 --- a/exercises/005-previous_and_next/app.py +++ b/exercises/005-previous_and_next/app.py @@ -1,7 +1,9 @@ # Complete the function to return the previous and next number of a given number def previous_next(num): # Your code here - return None + valor = ((num-1), (num+1)) + + return valor # Invoke the function with any integer as its argument diff --git a/exercises/006-apple_sharing/app.py b/exercises/006-apple_sharing/app.py index 2c17d877..3744a1bc 100644 --- a/exercises/006-apple_sharing/app.py +++ b/exercises/006-apple_sharing/app.py @@ -1,6 +1,8 @@ def apple_sharing(n,k): # Your code here - return None + result = k // n + resto = k % n + return result,resto print(apple_sharing(6,50)) diff --git a/exercises/006.1-square_value_of_number/app.py b/exercises/006.1-square_value_of_number/app.py index 086d1e41..b2fc5d77 100644 --- a/exercises/006.1-square_value_of_number/app.py +++ b/exercises/006.1-square_value_of_number/app.py @@ -1,5 +1,5 @@ def square(num): # Your code here - return None + return num ** 2 print(square(6)) diff --git a/exercises/007-hours_and_minutes/app.py b/exercises/007-hours_and_minutes/app.py index 14ce499b..4fa04357 100644 --- a/exercises/007-hours_and_minutes/app.py +++ b/exercises/007-hours_and_minutes/app.py @@ -1,6 +1,10 @@ def hours_minutes(seconds): # Your code here - return None + horas = seconds // 3600 + segundos_restantes = seconds % 3600 + minutos = segundos_restantes // 60 + + return horas, minutos # Invoke the function and pass any integer as its argument print(hours_minutes(3900)) diff --git a/exercises/008-two_timestamps/app.py b/exercises/008-two_timestamps/app.py index ab47d89d..24468334 100644 --- a/exercises/008-two_timestamps/app.py +++ b/exercises/008-two_timestamps/app.py @@ -1,6 +1,9 @@ def two_timestamp(hr1, min1, sec1, hr2, min2, sec2): - # Your code here - return None + # Your code here + hora1 = hr1 * 3600 + min1 * 60 + sec1 + hora2 = hr2 * 3600 + min2 * 60 + sec2 + result = hora2 - hora1 + return result # Invoke the function and pass two timestamps(6 intergers) as its arguments diff --git a/exercises/009-two_digits/app.py b/exercises/009-two_digits/app.py index a8a424e7..d4d88073 100644 --- a/exercises/009-two_digits/app.py +++ b/exercises/009-two_digits/app.py @@ -1,7 +1,7 @@ # Complete the function to return the tens digit and the units digit of any interger def two_digits(number): # Your code here - return None + return (number // 10), (number % 10) # Invoke the function with any two digit integer as its argument diff --git a/exercises/010-swap_digits/app.py b/exercises/010-swap_digits/app.py index 9fc7ba9a..da80ffab 100644 --- a/exercises/010-swap_digits/app.py +++ b/exercises/010-swap_digits/app.py @@ -1,7 +1,8 @@ # Complete the function to return the swapped digits of a given two-digit integer def swap_digits(num): # Your code here - return None + result = str(num % 10 ) + str(num // 10) + return int(result) # Invoke the function with any two-digit integer as its argument print(swap_digits(30)) diff --git a/exercises/011-last_two_digits/app.py b/exercises/011-last_two_digits/app.py index cf00ec28..f207a80e 100644 --- a/exercises/011-last_two_digits/app.py +++ b/exercises/011-last_two_digits/app.py @@ -1,6 +1,8 @@ # Complete the function to print the last two digits of an integer greater than 9 def last_two_digits(num): - return None + if num > 9: + result = str(num)[-2:] + return int(result) # Invoke the function with any integer greater than 9 -print(last_two_digits()) +print(last_two_digits(1149)) diff --git a/exercises/012-tens_digit/app.py b/exercises/012-tens_digit/app.py index 467c2902..e9b0731d 100644 --- a/exercises/012-tens_digit/app.py +++ b/exercises/012-tens_digit/app.py @@ -1,7 +1,8 @@ # Complete the function to return the tens digit of a given integer def tens_digit(num): - return None + result = str(num)[-2] + return int(result) # Invoke the function with any integer -print(tens_digit()) +print(tens_digit(179)) diff --git a/exercises/013-sum_of_digits/app.py b/exercises/013-sum_of_digits/app.py index 502dff35..4b0d5936 100644 --- a/exercises/013-sum_of_digits/app.py +++ b/exercises/013-sum_of_digits/app.py @@ -1,7 +1,11 @@ # Complete the function "digits_sum" so that it prints the sum of a three-digit number def digits_sum(num): - return None + result1 = 0 + for i in range(3): + result = str(num)[i] + result1 = result1 + int(result) + return result1 # Invoke the function with any three-digit number -print(digits_sum(123)) +print(digits_sum(789)) diff --git a/exercises/014-digit_after_decimal_point/app.py b/exercises/014-digit_after_decimal_point/app.py index 01940696..c29e9e76 100644 --- a/exercises/014-digit_after_decimal_point/app.py +++ b/exercises/014-digit_after_decimal_point/app.py @@ -1,7 +1,8 @@ # Complete the function to return the first digit to the right of the decimal point def first_digit(num): - return None + + return int(str(num)[2]) # Invoke the function with a positive real number. ex. 34.33 -print(first_digit()) +print(first_digit(6.24)) diff --git a/exercises/015-car_route/app.py b/exercises/015-car_route/app.py index 909df947..28a71c92 100644 --- a/exercises/015-car_route/app.py +++ b/exercises/015-car_route/app.py @@ -1,7 +1,10 @@ # Complete the function to return the amount of days it will take to cover a route +import math + def car_route(n,m): - return None + result = math.ceil (m / n) + return result # Invoke the function with two integers -print(car_route()) +print(car_route(30,90)) diff --git a/exercises/016-century/app.py b/exercises/016-century/app.py index 54c39550..49f0ee11 100644 --- a/exercises/016-century/app.py +++ b/exercises/016-century/app.py @@ -1,7 +1,13 @@ # Complete the function to return the respective number of the century +import math def century(year): - return None + if year % 100 == 0: + return (year // 100) + else: + return (year // 100 + 1) + # Invoke the function with any given year -print(century()) +print(century(1500)) + diff --git a/exercises/017-total_cost/app.py b/exercises/017-total_cost/app.py index cc578749..aa5e17e6 100644 --- a/exercises/017-total_cost/app.py +++ b/exercises/017-total_cost/app.py @@ -1,6 +1,8 @@ # Complete the function to return the total cost in dollars and cents of (n) cupcakes def total_cost(d, c, n): - return None + valor1 = d * n + valor2 = c * n + return valor1, valor2 # Invoke the function with three integers: total_cost(dollars, cents, number_of_cupcakes) diff --git a/exercises/018-day_of_week/app.py b/exercises/018-day_of_week/app.py index 110ad973..b73d12d6 100644 --- a/exercises/018-day_of_week/app.py +++ b/exercises/018-day_of_week/app.py @@ -1,7 +1,7 @@ # Complete the function to return the number of day of the week for k'th day of year def day_of_week(k): - return None + return (3 + k) % 7 # Invoke function day_of_week with an integer between 1 and 365 -print(day_of_week()) +print(day_of_week(1)) diff --git a/exercises/019-digital_clock/app.py b/exercises/019-digital_clock/app.py index 1862864d..8a2845f6 100644 --- a/exercises/019-digital_clock/app.py +++ b/exercises/019-digital_clock/app.py @@ -1,6 +1,10 @@ # Complete the function to return how many hours and minutes are displayed on the 24h digital clock def digital_clock(n): - return None + horas = n // 60 + minutos = n % 60 + + return horas, minutos # Invoke the function with any integer (minutes after midnight) -print(digital_clock()) +print(digital_clock(150)) + diff --git a/exercises/020-factorial/app.py b/exercises/020-factorial/app.py index fce62c1d..43443ed6 100644 --- a/exercises/020-factorial/app.py +++ b/exercises/020-factorial/app.py @@ -1 +1,11 @@ # Your code here +def factorial(n): + fact = 1 + + for i in range(1, n+1): + fact = fact * i + + return fact + +print(factorial(8)) + diff --git a/exercises/021-square_root/app.py b/exercises/021-square_root/app.py index fce62c1d..6773c7da 100644 --- a/exercises/021-square_root/app.py +++ b/exercises/021-square_root/app.py @@ -1 +1,6 @@ # Your code here +import math +def square_root(n): + return round((math.sqrt(n)),2) + +print(square_root(50)) diff --git a/exercises/022-Integral/app.py b/exercises/022-Integral/app.py index a51f0856..a7848161 100644 --- a/exercises/022-Integral/app.py +++ b/exercises/022-Integral/app.py @@ -1 +1,12 @@ # Your code here + +def squares_dictionary(num): + diccionario = {} + for i in range(num): + diccionario[i+1] = (i+1) ** 2 + + + return diccionario + +squares_dictionary(8) + diff --git a/exercises/023-list-and-tuple/app.py b/exercises/023-list-and-tuple/app.py index a51f0856..521e2f3a 100644 --- a/exercises/023-list-and-tuple/app.py +++ b/exercises/023-list-and-tuple/app.py @@ -1 +1,9 @@ # Your code here +def list_and_tuple(*args): + lista = [] + for arg in args: + lista.append(str(arg)) + tupla = tuple(lista) + return lista, tupla + +list_and_tuple(34,67,55,33,12,98,33,4555,6777,0,88) \ No newline at end of file diff --git a/exercises/024-class-with-two-methods/app.py b/exercises/024-class-with-two-methods/app.py index a51f0856..3c0ba0b0 100644 --- a/exercises/024-class-with-two-methods/app.py +++ b/exercises/024-class-with-two-methods/app.py @@ -1 +1,14 @@ # Your code here +class InputOutString: + def __init__(self): + self.input_string = "" + + def get_string(self): + self.input_string = input("Enter a string: ") + + def print_string(self): + print(self.input_string.upper()) + +string_object = InputOutString() +string_object.get_string() +string_object.print_string() diff --git a/exercises/025-print-formula/app.py b/exercises/025-print-formula/app.py index a51f0856..20e21a62 100644 --- a/exercises/025-print-formula/app.py +++ b/exercises/025-print-formula/app.py @@ -1 +1,9 @@ # Your code here +import math +def print_formula(d): + c = 50 + h = 30 + valor = round(math.sqrt((2 * c * d) / h),0) + return valor + +print(print_formula(150)) \ No newline at end of file diff --git a/exercises/026-two-dimensional-array/app.py b/exercises/026-two-dimensional-array/app.py index a51f0856..78236a58 100644 --- a/exercises/026-two-dimensional-array/app.py +++ b/exercises/026-two-dimensional-array/app.py @@ -1 +1,11 @@ # Your code here +def two_dimensional_list(x,y): + matriz_final = [] + for i in range(x): + matriz = [] + for j in range(y): + matriz.append(i*j) + matriz_final.append(matriz) + return matriz_final + +two_dimensional_list(3,5) \ No newline at end of file diff --git a/exercises/027-sequence-of-words/app.py b/exercises/027-sequence-of-words/app.py index a51f0856..c8d54b5e 100644 --- a/exercises/027-sequence-of-words/app.py +++ b/exercises/027-sequence-of-words/app.py @@ -1 +1,8 @@ # Your code here +def sequence_of_words(words): + palabras = words.split(",") + palabras.sort() + return (','.join(palabras)) + + +print(sequence_of_words("without,hello,bag,world")) \ No newline at end of file diff --git a/exercises/028-sequence-of-lines/app.py b/exercises/028-sequence-of-lines/app.py index a51f0856..ca3b1e1e 100644 --- a/exercises/028-sequence-of-lines/app.py +++ b/exercises/028-sequence-of-lines/app.py @@ -1 +1,5 @@ # Your code here +def lines(words): + return words.upper() + +lines("Hello world, practice makes perfect") \ No newline at end of file diff --git a/exercises/029-remove-duplicate-words/app.py b/exercises/029-remove-duplicate-words/app.py index fce62c1d..0dcd6b71 100644 --- a/exercises/029-remove-duplicate-words/app.py +++ b/exercises/029-remove-duplicate-words/app.py @@ -1 +1,8 @@ # Your code here +def remove_duplicate_words(words): + palabras = words.split(" ") + palabras = list(set(palabras)) + palabras.sort() + return (" ".join(palabras)) + +print(remove_duplicate_words("hello world and practice makes perfect and hello world again")) \ No newline at end of file diff --git a/exercises/030-divisable-binary/app.py b/exercises/030-divisable-binary/app.py index a51f0856..d9881a97 100644 --- a/exercises/030-divisable-binary/app.py +++ b/exercises/030-divisable-binary/app.py @@ -1 +1,10 @@ # Your code here +def divisible_binary(binary_): + bin_ = binary_.split(",") + lista =[] + for i in bin_: + if int(i,2)%5 == 0: + lista.append(i) + return ",".join(lista) + +print(divisible_binary("1010,1010,1010,1010")) \ No newline at end of file diff --git a/exercises/031-sum-eigth-digit/app.py b/exercises/031-sum-eigth-digit/app.py index a51f0856..8dfe3e71 100644 --- a/exercises/031-sum-eigth-digit/app.py +++ b/exercises/031-sum-eigth-digit/app.py @@ -1 +1,11 @@ # Your code here +def all_digits_even(): + lista = [] + for i in range(1000,3001): + if i%2 ==0: + lista.append(str(i)) + print(lista) + return (lista) + + +all_digits_even() \ No newline at end of file diff --git a/exercises/032-numbers-of-letters-and-digits/app.py b/exercises/032-numbers-of-letters-and-digits/app.py index a51f0856..66219dd5 100644 --- a/exercises/032-numbers-of-letters-and-digits/app.py +++ b/exercises/032-numbers-of-letters-and-digits/app.py @@ -1 +1,15 @@ # Your code here +def letters_and_digits(texto): + valor = {"LETTERS": 0, "DIGITS": 0} + for letra in texto: + if letra.isalpha(): + valor['LETTERS'] += 1 + elif letra.isdigit(): + valor['DIGITS'] += 1 + else: + pass + + return f"LETTERS {valor['LETTERS']} DIGITS {valor['DIGITS']}" + + +print(letters_and_digits("hello world! 123")) diff --git a/exercises/033-number-of-uppercase/app.py b/exercises/033-number-of-uppercase/app.py index a51f0856..72fa1b97 100644 --- a/exercises/033-number-of-uppercase/app.py +++ b/exercises/033-number-of-uppercase/app.py @@ -1 +1,14 @@ # Your code here +def number_of_uppercase(texto): + valor = {"UPPERCASE": 0, "LOWERCASE": 0} + for letra in texto: + if letra.islower() and letra.isalpha(): + valor['LOWERCASE'] += 1 + elif letra.isupper() and letra.isalpha(): + valor['UPPERCASE'] += 1 + + + return f"UPPERCASE {valor['UPPERCASE']} LOWERCASE {valor['LOWERCASE']}" + + +print(number_of_uppercase("Hello world!")) \ No newline at end of file diff --git a/exercises/034-a_aa_aaa_aaaa/app.py b/exercises/034-a_aa_aaa_aaaa/app.py index a51f0856..5b65bdcf 100644 --- a/exercises/034-a_aa_aaa_aaaa/app.py +++ b/exercises/034-a_aa_aaa_aaaa/app.py @@ -1 +1,12 @@ # Your code here +def computed_value(num): + valor = 0 + for i in range(1, 5): + numero = int(str(num) * i) + print("Numero", numero) + valor += numero + print("Valor", valor) + return valor + #return num + num*2 + num*111 + num*1111 + +print(computed_value(123)) \ No newline at end of file diff --git a/exercises/035-square-each-odd-number/app.py b/exercises/035-square-each-odd-number/app.py index a51f0856..c28d9c6b 100644 --- a/exercises/035-square-each-odd-number/app.py +++ b/exercises/035-square-each-odd-number/app.py @@ -1 +1,9 @@ # Your code here +def square_odd_numbers(text): + result = [] + num = text.split(",") + for i in num: + if int(i)%2 != 0: + result.append(int(i)**2) + return result +print(square_odd_numbers("1,2,3,4,5,6,7,8,9")) \ No newline at end of file diff --git a/exercises/036-net-amount/app.py b/exercises/036-net-amount/app.py index a51f0856..41593aa6 100644 --- a/exercises/036-net-amount/app.py +++ b/exercises/036-net-amount/app.py @@ -1 +1,15 @@ # Your code here +def net_amount(entrada): + result = 0 + valor = entrada.split(" ") + + for i in range(len(valor)): + if valor[i] == "D": + result += int(valor[i+1]) + elif valor[i] == "W": + result -= int(valor[i+1]) + + return result + +net_amount("D 300 D 300 W 200 D 100") +