[1]:
%reload_ext jupyter_ai
[2]:
%%ai chatgpt --format code
A program that asks me for my name and then greets me by my name, in Polish
[3]:
name = input("Jak masz na imię? ")
print("Cześć " + name + "!")
Jak masz na imię? foo
Cześć foo!
[4]:
%%ai chatgpt --format code
A function that computes the lowest common multiples of two integers, and a function that runs 5 test cases of the lowest common multiple function
[5]:
def lcm(x, y):
if x > y:
greater = x
else:
greater = y
while True:
if (greater % x == 0) and (greater % y == 0):
lcm = greater
break
greater += 1
return lcm
def test_lcm():
assert lcm(3, 5) == 15
assert lcm(7, 9) == 63
assert lcm(18, 24) == 72
assert lcm(10, 15) == 30
assert lcm(12, 16) == 48
test_lcm()
[ ]: