python_by_example/basic/basic.py
2023-11-11 00:09:22 -03:00

231 lines
6.0 KiB
Python

from . import basic01 as ex01
from . import basic02 as ex02
from . import basic03 as ex03
from . import basic04 as ex04
from . import basic05 as ex05
from . import basic06 as ex06
from . import basic07 as ex07
from common.common import (
print_challenges,
user_input,
run_func,
clear
)
def challenges01():
select_ok = False
while not select_ok:
clear()
i, ex1 = print_challenges(ex01.basics_001)
selection = user_input(i)
match selection:
case 1:
run_func(ex1.hola)
case 2:
run_func(ex1.hola2)
case 3:
run_func(ex1.pez)
case 4:
run_func(ex1.dos_nums)
case 5:
run_func(ex1.tres_nums)
case 6:
run_func(ex1.pizza)
case 7:
run_func(ex1.next_age)
case 8:
run_func(ex1.a_medias)
case 9:
run_func(ex1.tiempos)
case 10:
run_func(ex1.pounds)
case 11:
run_func(ex1.cabe)
case 'v':
return
case 's':
select_ok = True
exit(0)
case _:
continue
def challenges02():
select_ok = False
while not select_ok:
clear()
i, ex2 = print_challenges(ex02.basics_002)
selection = user_input(i)
match selection:
case 1:
run_func(ex2.mayor)
case 2:
run_func(ex2.muy_alto)
case 3:
run_func(ex2.gracias)
case 4:
run_func(ex2.fav_color)
case 5:
run_func(ex2.clima)
case 6:
run_func(ex2.edad_conducir)
case 7:
run_func(ex2.alto_bajo)
case 8:
run_func(ex2.uno_dos_tres)
case 'v':
return
case 's':
exit(0)
case _:
continue
def challenges03():
select_ok = False
while not select_ok:
clear()
i, ex3 = print_challenges(ex03.basics_003)
selection = user_input(i)
match selection:
case 1:
run_func(ex3.name_length)
case 2:
run_func(ex3.fullname_length)
case 3:
run_func(ex3.full_name_lower)
case 4:
run_func(ex3.nursery)
case 5:
run_func(ex3.any_mayus)
case 6:
run_func(ex3.mambo_name)
case 7:
run_func(ex3.pig_latin)
case 'v':
return
case 's':
exit(0)
case _:
continue
def challenges04():
select_ok = False
while not select_ok:
clear()
i, ex4 = print_challenges(ex04.basics_004)
selection = user_input(i)
match selection:
case 1:
run_func(ex4.decims)
case 2:
run_func(ex4.decims_round)
case 3:
run_func(ex4.square_root)
case 4:
run_func(ex4.pi_round)
case 5:
run_func(ex4.circle_area)
case 6:
run_func(ex4.cyl_vol)
case 7:
run_func(ex4.friendly_div)
case 8:
run_func(ex4.circ_trian)
case 'v':
return
case 's':
exit(0)
case _:
continue
def challenges05():
select_ok = False
while not select_ok:
clear()
i, ex5 = print_challenges(ex05.basics_005)
selection = user_input(i)
match selection:
case 1:
run_func(ex5.name_three)
case 2:
run_func(ex5.name_num)
case 3:
run_func(ex5.name_nl)
case 4:
run_func(ex5.name_nl_num)
case 5:
run_func(ex5.times_table)
case 6:
run_func(ex5.count_down)
case 7:
run_func(ex5.mambo_name)
case 8:
run_func(ex5.may_add)
case 9:
run_func(ex5.up_or_down)
case 10:
run_func(ex5.guests)
case 'v':
return
case 's':
exit(0)
case _:
continue
def challenges06():
select_ok = False
while not select_ok:
clear()
i, ex6 = print_challenges(ex06.basics_006)
selection = user_input(i)
match selection:
case 1:
run_func(ex6.over50)
case 2:
run_func(ex6.last_5)
case 3:
run_func(ex6.add_another)
case 4:
run_func(ex6.party)
case 5:
run_func(ex6.compnum)
case 6:
run_func(ex6.between)
case 7:
run_func(ex6.bottles)
case 'v':
return
case 's':
exit(0)
case _:
continue
def challenges07():
select_ok = False
while not select_ok:
clear()
i, ex7 = print_challenges(ex07.basics_007)
selection = user_input(i)
match selection:
case 1:
run_func(ex7.rand_range)
case 2:
run_func(ex7.rand_choice)
case 3:
run_func(ex7.rand_game)
case 4:
run_func(ex7.rand_pick)
case 5:
run_func(ex7.rand_10)
case 6:
run_func(ex7.rand_10_upgrade)
case 7:
run_func(ex7.rand_quiz)
case 8:
run_func(ex7.rand_color)
case 'v':
return
case 's':
exit(0)
case _:
continue