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/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..6ac0c57b 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..20294c80 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 f"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..f38fad1b 100644 --- a/exercises/005-previous_and_next/app.py +++ b/exercises/005-previous_and_next/app.py @@ -1,7 +1,7 @@ # Complete the function to return the previous and next number of a given number def previous_next(num): # Your code here - return None + return (num-1, num+1) # 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..b8efcf7b 100644 --- a/exercises/006-apple_sharing/app.py +++ b/exercises/006-apple_sharing/app.py @@ -1,6 +1,6 @@ def apple_sharing(n,k): # Your code here - return None + return (int(k/n), k%n) 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..8e9ec110 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..792ed7b3 100644 --- a/exercises/007-hours_and_minutes/app.py +++ b/exercises/007-hours_and_minutes/app.py @@ -1,6 +1,6 @@ def hours_minutes(seconds): # Your code here - return None + return (int(seconds/3600), int((seconds%3600)/60)) # 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..048bf33f 100644 --- a/exercises/008-two_timestamps/app.py +++ b/exercises/008-two_timestamps/app.py @@ -1,6 +1,6 @@ def two_timestamp(hr1, min1, sec1, hr2, min2, sec2): # Your code here - return None + return (hr2*3600)+(min2*60)+sec2 - (hr1*3600)-(min1*60)-sec1 # 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..6e17c424 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..770feea1 100644 --- a/exercises/010-swap_digits/app.py +++ b/exercises/010-swap_digits/app.py @@ -1,7 +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 + return int(str(num%10)+str(num//10)) # 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..87200b89 100644 --- a/exercises/011-last_two_digits/app.py +++ b/exercises/011-last_two_digits/app.py @@ -1,6 +1,6 @@ # Complete the function to print the last two digits of an integer greater than 9 def last_two_digits(num): - return None + return int(str(num)[-2]+str(num)[-1]) # Invoke the function with any integer greater than 9 -print(last_two_digits()) +print(last_two_digits(8825)) diff --git a/exercises/012-tens_digit/app.py b/exercises/012-tens_digit/app.py index 467c2902..4231e816 100644 --- a/exercises/012-tens_digit/app.py +++ b/exercises/012-tens_digit/app.py @@ -1,7 +1,7 @@ # Complete the function to return the tens digit of a given integer def tens_digit(num): - return None + return int(str(num)[-2]) # 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..931f7fe2 100644 --- a/exercises/013-sum_of_digits/app.py +++ b/exercises/013-sum_of_digits/app.py @@ -1,6 +1,6 @@ # Complete the function "digits_sum" so that it prints the sum of a three-digit number def digits_sum(num): - return None + return (num//100)+((num//10)%10)+(num%10) # Invoke the function with any three-digit number diff --git a/exercises/014-digit_after_decimal_point/app.py b/exercises/014-digit_after_decimal_point/app.py index 01940696..5adc5a27 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 +import math def first_digit(num): - return None + return int(str(num).split(".")[1][0]) # Invoke the function with a positive real number. ex. 34.33 -print(first_digit()) +print(first_digit(1.79)) diff --git a/exercises/015-car_route/app.py b/exercises/015-car_route/app.py index 909df947..304b61ce 100644 --- a/exercises/015-car_route/app.py +++ b/exercises/015-car_route/app.py @@ -1,7 +1,9 @@ # 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 + return math.floor(m/n) # Invoke the function with two integers -print(car_route()) +print(car_route(35,50)) diff --git a/exercises/016-century/app.py b/exercises/016-century/app.py index 54c39550..0fe518a1 100644 --- a/exercises/016-century/app.py +++ b/exercises/016-century/app.py @@ -1,7 +1,12 @@ # Complete the function to return the respective number of the century +import math + def century(year): - return None + if year % 100 == 0: + return math.floor(year/100) + else: + return math.floor((year/100))+1 # Invoke the function with any given year -print(century()) +print(century(2024)) diff --git a/exercises/017-total_cost/app.py b/exercises/017-total_cost/app.py index cc578749..608c1a0b 100644 --- a/exercises/017-total_cost/app.py +++ b/exercises/017-total_cost/app.py @@ -1,6 +1,13 @@ # Complete the function to return the total cost in dollars and cents of (n) cupcakes +import math + def total_cost(d, c, n): - return None + dollars = n*d + cents = n*c + if cents >= 100: + dollars += math.floor(cents/100) + cents = cents%100 + return (dollars, cents) # 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..ffcf2e28 100644 --- a/exercises/018-day_of_week/app.py +++ b/exercises/018-day_of_week/app.py @@ -1,7 +1,9 @@ # 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 + day=(3+k)%7 + return day + # Invoke function day_of_week with an integer between 1 and 365 -print(day_of_week()) +print(day_of_week(4)) diff --git a/exercises/019-digital_clock/app.py b/exercises/019-digital_clock/app.py index 1862864d..17107411 100644 --- a/exercises/019-digital_clock/app.py +++ b/exercises/019-digital_clock/app.py @@ -1,6 +1,8 @@ # Complete the function to return how many hours and minutes are displayed on the 24h digital clock +import math + def digital_clock(n): - return None + return (math.floor(n/60), n%60) # Invoke the function with any integer (minutes after midnight) -print(digital_clock()) +print(digital_clock(1439)) diff --git a/exercises/020-factorial/app.py b/exercises/020-factorial/app.py index fce62c1d..0abb36b7 100644 --- a/exercises/020-factorial/app.py +++ b/exercises/020-factorial/app.py @@ -1 +1,7 @@ # Your code here +def factorial (n): + result = 1 + for i in range(1, n + 1): + result *= i + return result +print(factorial(8)) \ No newline at end of file diff --git a/exercises/021-square_root/app.py b/exercises/021-square_root/app.py index fce62c1d..5f394c22 100644 --- a/exercises/021-square_root/app.py +++ b/exercises/021-square_root/app.py @@ -1 +1,7 @@ # Your code here +import math + +def square_root(n): + return round(math.sqrt(n), 2) + +print(square_root(7)) \ No newline at end of file diff --git a/exercises/022-Integral/app.py b/exercises/022-Integral/app.py index a51f0856..da2a9f06 100644 --- a/exercises/022-Integral/app.py +++ b/exercises/022-Integral/app.py @@ -1 +1,8 @@ # Your code here +def squares_dictionary(n): + sqr_dict = {} + for i in range(1, n+1): + sqr_dict[i]=i*i + return sqr_dict + +print(squares_dictionary(8)) \ No newline at end of file diff --git a/exercises/023-list-and-tuple/app.py b/exercises/023-list-and-tuple/app.py index a51f0856..9f233b7f 100644 --- a/exercises/023-list-and-tuple/app.py +++ b/exercises/023-list-and-tuple/app.py @@ -1 +1,8 @@ # Your code here +def list_and_tuple(*arg): + args=[] + for i in arg: + args.append(str(i)) + return (list(args), tuple(args)) + +print(list_and_tuple(34,67,55,33,12,98)) \ No newline at end of file