Skip to content

Codespace cuddly computing machine g447x79q9xj7f9vx6 #73

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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())
7 changes: 7 additions & 0 deletions .learn/resets/016-century/app.py
Original file line number Diff line number Diff line change
@@ -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())
7 changes: 7 additions & 0 deletions .learn/resets/017-total_cost/app.py
Original file line number Diff line number Diff line change
@@ -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))
7 changes: 7 additions & 0 deletions .learn/resets/018-day_of_week/app.py
Original file line number Diff line number Diff line change
@@ -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())
6 changes: 6 additions & 0 deletions .learn/resets/019-digital_clock/app.py
Original file line number Diff line number Diff line change
@@ -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())
1 change: 1 addition & 0 deletions .learn/resets/020-factorial/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Your code here
1 change: 1 addition & 0 deletions .learn/resets/021-square_root/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Your code here
1 change: 1 addition & 0 deletions .learn/resets/022-Integral/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Your code here
1 change: 1 addition & 0 deletions .learn/resets/023-list-and-tuple/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Your code here
1 change: 1 addition & 0 deletions .learn/resets/024-class-with-two-methods/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Your code here
1 change: 1 addition & 0 deletions .learn/resets/025-print-formula/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Your code here
1 change: 1 addition & 0 deletions .learn/resets/026-two-dimensional-array/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Your code here
1 change: 1 addition & 0 deletions .learn/resets/027-sequence-of-words/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Your code here
1 change: 1 addition & 0 deletions .learn/resets/028-sequence-of-lines/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Your code here
1 change: 1 addition & 0 deletions .learn/resets/029-remove-duplicate-words/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Your code here
1 change: 1 addition & 0 deletions .learn/resets/030-divisable-binary/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Your code here
1 change: 1 addition & 0 deletions .learn/resets/031-sum-eigth-digit/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Your code here
1 change: 1 addition & 0 deletions .learn/resets/032-numbers-of-letters-and-digits/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Your code here
1 change: 1 addition & 0 deletions .learn/resets/033-number-of-uppercase/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Your code here
1 change: 1 addition & 0 deletions .learn/resets/034-a_aa_aaa_aaaa/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Your code here
1 change: 1 addition & 0 deletions .learn/resets/035-square-each-odd-number/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Your code here
1 change: 1 addition & 0 deletions .learn/resets/036-net-amount/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Your code here
1 change: 1 addition & 0 deletions .learn/resets/037-validity-of-password/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Your code here
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
@@ -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 "Hello, " + name + "!"

# Invoke the function with your name as the function's argument
print(hello_name("Bob"))
4 changes: 3 additions & 1 deletion exercises/005-previous_and_next/app.py
Original file line number Diff line number Diff line change
@@ -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
4 changes: 3 additions & 1 deletion exercises/006-apple_sharing/app.py
Original file line number Diff line number Diff line change
@@ -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))
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))
6 changes: 5 additions & 1 deletion exercises/007-hours_and_minutes/app.py
Original file line number Diff line number Diff line change
@@ -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))
7 changes: 5 additions & 2 deletions exercises/008-two_timestamps/app.py
Original file line number Diff line number Diff line change
@@ -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
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
3 changes: 2 additions & 1 deletion exercises/010-swap_digits/app.py
Original file line number Diff line number Diff line change
@@ -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))
6 changes: 4 additions & 2 deletions exercises/011-last_two_digits/app.py
Original file line number Diff line number Diff line change
@@ -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))
5 changes: 3 additions & 2 deletions exercises/012-tens_digit/app.py
Original file line number Diff line number Diff line change
@@ -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))
8 changes: 6 additions & 2 deletions exercises/013-sum_of_digits/app.py
Original file line number Diff line number Diff line change
@@ -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))
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
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))
7 changes: 5 additions & 2 deletions exercises/015-car_route/app.py
Original file line number Diff line number Diff line change
@@ -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))
10 changes: 8 additions & 2 deletions exercises/016-century/app.py
Original file line number Diff line number Diff line change
@@ -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))

4 changes: 3 additions & 1 deletion exercises/017-total_cost/app.py
Original file line number Diff line number Diff line change
@@ -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)
4 changes: 2 additions & 2 deletions exercises/018-day_of_week/app.py
Original file line number Diff line number Diff line change
@@ -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))
8 changes: 6 additions & 2 deletions exercises/019-digital_clock/app.py
Original file line number Diff line number Diff line change
@@ -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))

10 changes: 10 additions & 0 deletions exercises/020-factorial/app.py
Original file line number Diff line number Diff line change
@@ -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))

5 changes: 5 additions & 0 deletions exercises/021-square_root/app.py
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
# Your code here
import math
def square_root(n):
return round((math.sqrt(n)),2)

print(square_root(50))
11 changes: 11 additions & 0 deletions exercises/022-Integral/app.py
Original file line number Diff line number Diff line change
@@ -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)

8 changes: 8 additions & 0 deletions exercises/023-list-and-tuple/app.py
Original file line number Diff line number Diff line change
@@ -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)
13 changes: 13 additions & 0 deletions exercises/024-class-with-two-methods/app.py
Original file line number Diff line number Diff line change
@@ -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()
8 changes: 8 additions & 0 deletions exercises/025-print-formula/app.py
Original file line number Diff line number Diff line change
@@ -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))
10 changes: 10 additions & 0 deletions exercises/026-two-dimensional-array/app.py
Original file line number Diff line number Diff line change
@@ -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)
7 changes: 7 additions & 0 deletions exercises/027-sequence-of-words/app.py
Original file line number Diff line number Diff line change
@@ -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"))
4 changes: 4 additions & 0 deletions exercises/028-sequence-of-lines/app.py
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
# Your code here
def lines(words):
return words.upper()

lines("Hello world, practice makes perfect")
7 changes: 7 additions & 0 deletions exercises/029-remove-duplicate-words/app.py
Original file line number Diff line number Diff line change
@@ -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"))
9 changes: 9 additions & 0 deletions exercises/030-divisable-binary/app.py
Original file line number Diff line number Diff line change
@@ -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"))
10 changes: 10 additions & 0 deletions exercises/031-sum-eigth-digit/app.py
Original file line number Diff line number Diff line change
@@ -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()
14 changes: 14 additions & 0 deletions exercises/032-numbers-of-letters-and-digits/app.py
Original file line number Diff line number Diff line change
@@ -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"))
13 changes: 13 additions & 0 deletions exercises/033-number-of-uppercase/app.py
Original file line number Diff line number Diff line change
@@ -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!"))
11 changes: 11 additions & 0 deletions exercises/034-a_aa_aaa_aaaa/app.py
Original file line number Diff line number Diff line change
@@ -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))
8 changes: 8 additions & 0 deletions exercises/035-square-each-odd-number/app.py
Original file line number Diff line number Diff line change
@@ -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"))
14 changes: 14 additions & 0 deletions exercises/036-net-amount/app.py
Original file line number Diff line number Diff line change
@@ -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")