uaveiro-leci/1ano/fp/aula03/poly.py

25 lines
519 B
Python
Raw Normal View History

2022-10-11 19:27:51 +00:00
# Esta função implementa g(x) = 8 - x**3
2022-10-14 19:55:59 +00:00
g = lambda x: 8 - x**3
2022-10-11 19:27:51 +00:00
# Defina uma função que implemente p(x) = x**2 + 2x + 3
2022-10-14 19:55:59 +00:00
p = lambda x: x**2 + 2*x + 3
2022-10-11 19:27:51 +00:00
def main():
# Mostra alguns valores da função g:
print("g(1) =", g(1))
print("g(2) =", g(2))
print("g(10) =", g(10))
# Acrescente instruções para mostrar os valores de
# p(1), p(2), p(10) e g(1 + p(3)).
2022-10-18 17:18:56 +00:00
print(f"""
p(1) = {p(1)}
p(2) = {p(2)}
p(10) = {p(10)}
g(1 + p(3)) = {g(1 + p(3))}
""")
2022-10-11 19:27:51 +00:00
if __name__ == '__main__':
main()