๐Ÿ‘ฉ‍๐Ÿ’ป ์•Œ๊ณ ๋ฆฌ์ฆ˜/๐Ÿข PYTHON

format ํ•จ์ˆ˜

์˜ค๋ธŒ ๐Ÿง™‍โ™‚๏ธ 2023. 9. 12. 02:08

"2์˜ n์ œ๊ณฑ"์„ ์ถœ๋ ฅํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ

for i in range(11):
    print(f"2^{i}  = {2**i}")

** -> ๊ฑฐ๋“ญ์ œ๊ณฑ

for i in range(11):
    print("{}^{} = {}".format(2, i, 2 ** i))

format ํ•จ์ˆ˜

(a, b๊ฐ€ ๋ณ€์ˆ˜๋ผ๊ณ  ์ณค์„ ๋•Œ)
print('{2} x {1} = 6'.format(a, b, a * b))