INF201/uke1/3:sq_table.py
2023-10-26 09:04:31 +02:00

18 lines
493 B
Python

def table(c1, c2, c3):
t = "{:^10}|{:^10}|{:^10}|\n".format(c1[0],c2[0],c3[0])
t += ("-"*len(t)+"\n")
for n in range(1, len(c1)):
t += ("{:^10}|{:^10}|{:^10}|\n".format(c1[n],c2[n],c3[n]))
return(t)
def main():
n_list = ["x"]
sq_list = [""]
cube_list = [""]
for n in range(11):
n_list.append(n)
sq_list.append(n**2)
cube_list.append(n**3)
print(table(n_list, sq_list, cube_list))
if __name__ == "__main__":
main()