Commit 90fdd7cc by Patryk Czarnik

kwadraty i sześciany

parent c38f4a83
'''
Program w kolejnych liniach wypisuje kolejne liczby z zakresu od 1 do 100
i obok każdej takiej liczby wypisuje tę liczbę podniesioną do kwadratu (i ew. sześcianu).
1 1
2 4
3 9
4 16
'''
for i in range(1, 101):
# print(i, i**2, i**3)
# print(f'{i} {i**2} {i**3}')
print(f'{i:3} {i**2:5} {i**3:7}')
# print(f'{i:3} {i*i:5} {i*i*i:7}')
limit = int(input('Podaj limit: '))
szer1 = len(str(limit))
szer2 = len(str(limit**2))
szer3 = len(str(limit**3))
for i in range(1, limit+1):
# print(f'|{i:{szer1}}|{i**2:{szer2}}|{i**3:{szer3}}|')
print(f'{i:{szer1}} {i**2:{szer2}} {i**3:{szer3}}')
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment