Skip to content

Ejercicios practicados #74

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .learn/resets/001-hello_world/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Your code here
8 changes: 8 additions & 0 deletions .learn/resets/002-sum_of_three_numbers/app.py
Original file line number Diff line number Diff line change
@@ -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)
7 changes: 7 additions & 0 deletions .learn/resets/003-area_of_right_triangle/app.py
Original file line number Diff line number Diff line change
@@ -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))
7 changes: 7 additions & 0 deletions .learn/resets/004-hello_harry/app.py
Original file line number Diff line number Diff line change
@@ -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"))
8 changes: 8 additions & 0 deletions .learn/resets/005-previous_and_next/app.py
Original file line number Diff line number Diff line change
@@ -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))
6 changes: 6 additions & 0 deletions .learn/resets/006-apple_sharing/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
def apple_sharing(n,k):
# Your code here
return None


print(apple_sharing(6,50))
5 changes: 5 additions & 0 deletions .learn/resets/006.1-square_value_of_number/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
def square(num):
# Your code here
return None

print(square(6))
6 changes: 6 additions & 0 deletions .learn/resets/007-hours_and_minutes/app.py
Original file line number Diff line number Diff line change
@@ -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))
7 changes: 7 additions & 0 deletions .learn/resets/008-two_timestamps/app.py
Original file line number Diff line number Diff line change
@@ -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))
8 changes: 8 additions & 0 deletions .learn/resets/009-two_digits/app.py
Original file line number Diff line number Diff line change
@@ -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))
7 changes: 7 additions & 0 deletions .learn/resets/010-swap_digits/app.py
Original file line number Diff line number Diff line change
@@ -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))
6 changes: 6 additions & 0 deletions .learn/resets/011-last_two_digits/app.py
Original file line number Diff line number Diff line change
@@ -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())
7 changes: 7 additions & 0 deletions .learn/resets/012-tens_digit/app.py
Original file line number Diff line number Diff line change
@@ -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())
7 changes: 7 additions & 0 deletions .learn/resets/013-sum_of_digits/app.py
Original file line number Diff line number Diff line change
@@ -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))
7 changes: 7 additions & 0 deletions .learn/resets/014-digit_after_decimal_point/app.py
Original file line number Diff line number Diff line change
@@ -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())
7 changes: 7 additions & 0 deletions .learn/resets/015-car_route/app.py
Original file line number Diff line number Diff line change
@@ -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())
1 change: 1 addition & 0 deletions exercises/001-hello_world/app.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
# Your code here
print("Hello World")
2 changes: 1 addition & 1 deletion exercises/002-sum_of_three_numbers/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@


# Print here the sum of all three inputs
print(first_number+second_number)
print(first_number+second_number+third_number)
2 changes: 1 addition & 1 deletion exercises/003-area_of_right_triangle/app.py
Original file line number Diff line number Diff line change
@@ -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))
2 changes: 1 addition & 1 deletion exercises/004-hello_harry/app.py
Original file line number Diff line number Diff line change
@@ -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"))
2 changes: 1 addition & 1 deletion exercises/005-previous_and_next/app.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion exercises/006-apple_sharing/app.py
Original file line number Diff line number Diff line change
@@ -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))
2 changes: 1 addition & 1 deletion exercises/006.1-square_value_of_number/app.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
def square(num):
# Your code here
return None
return num**2

print(square(6))
2 changes: 1 addition & 1 deletion exercises/007-hours_and_minutes/app.py
Original file line number Diff line number Diff line change
@@ -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))
2 changes: 1 addition & 1 deletion exercises/008-two_timestamps/app.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion exercises/009-two_digits/app.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion exercises/010-swap_digits/app.py
Original file line number Diff line number Diff line change
@@ -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))
4 changes: 2 additions & 2 deletions exercises/011-last_two_digits/app.py
Original file line number Diff line number Diff line change
@@ -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))
4 changes: 2 additions & 2 deletions exercises/012-tens_digit/app.py
Original file line number Diff line number Diff line change
@@ -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))
2 changes: 1 addition & 1 deletion exercises/013-sum_of_digits/app.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 3 additions & 2 deletions exercises/014-digit_after_decimal_point/app.py
Original file line number Diff line number Diff line change
@@ -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))
6 changes: 4 additions & 2 deletions exercises/015-car_route/app.py
Original file line number Diff line number Diff line change
@@ -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))
Loading