๐ง๋ฌธ์
-
wage = 5 # ์๊ธ (1์๊ฐ์ 5๋ฌ๋ฌ) exchange_rate = 1142.16 # ํ์จ (1๋ฌ๋ฌ์ 1142.16์) print("{}์๊ฐ์ {}{} ๋ฒ์์ต๋๋ค.".format(1, wage * 1, "๋ฌ๋ฌ")) print("{}์๊ฐ์ {}{} ๋ฒ์์ต๋๋ค.".format(5, wage * 5, "๋ฌ๋ฌ")) print("{}์๊ฐ์ {:.1f}{} ๋ฒ์์ต๋๋ค.".format(1, wage * 1 * exchange_rate, "์")) print("{}์๊ฐ์ {:.1f}{} ๋ฒ์์ต๋๋ค.".format(5, wage * 5 * exchange_rate, "์")) *๋ฌธ์์ด ํฌ๋งทํ (format): print("~~{}~~{}~~".format(ํ๋ผ๋ฏธํฐ1, ํ๋ผ๋ฏธํฐ2)) ์ค๊ดํธ์ ๋ค์ด๊ฐ ๊ฐ๋ค์ ํ๋ผ๋ฏธํฐ๋ก..
ํ๋ก๊ทธ๋๋ฐ ๊ธฐ์ด in Python | ๋ฌธ์์ด ํฌ๋งทํ ์ฐ์ตwage = 5 # ์๊ธ (1์๊ฐ์ 5๋ฌ๋ฌ) exchange_rate = 1142.16 # ํ์จ (1๋ฌ๋ฌ์ 1142.16์) print("{}์๊ฐ์ {}{} ๋ฒ์์ต๋๋ค.".format(1, wage * 1, "๋ฌ๋ฌ")) print("{}์๊ฐ์ {}{} ๋ฒ์์ต๋๋ค.".format(5, wage * 5, "๋ฌ๋ฌ")) print("{}์๊ฐ์ {:.1f}{} ๋ฒ์์ต๋๋ค.".format(1, wage * 1 * exchange_rate, "์")) print("{}์๊ฐ์ {:.1f}{} ๋ฒ์์ต๋๋ค.".format(5, wage * 5 * exchange_rate, "์")) *๋ฌธ์์ด ํฌ๋งทํ (format): print("~~{}~~{}~~".format(ํ๋ผ๋ฏธํฐ1, ํ๋ผ๋ฏธํฐ2)) ์ค๊ดํธ์ ๋ค์ด๊ฐ ๊ฐ๋ค์ ํ๋ผ๋ฏธํฐ๋ก..
2022.01.13 -
print("""\'์๋ตํ๋ผ 1988\'์ ๋ง์ ์์ฒญ์๋ค์๊ฒ ์ฌ๋์ ๋ฐ์ ๋๋ผ๋ง์์. ๋ฐ์นด๋ฅดํธ๋ \"๋๋ ์๊ฐํ๋ค. ๊ณ ๋ก ์กด์ฌํ๋ค.\"๋ผ๊ณ ๋งํ๋ค.""") print("์ํ \'์ ์ธ๊ณ\'์์ \"๋๋ฃจ์~\"๋ผ๋ ๋์ฌ๊ฐ ์ ํํ๋ค.") *๋ฌธ์์ด ๋ฐ์ดํ ์ถ๋ ฅ : ๋ฐ์ดํ(', ") ์์ ์ญ์ฌ๋์ฌ(\)๋ฅผ ์ฌ์ฉํ๋ค. + ์์ ๋ฐ์ดํ(') ํน์ ํฐ ๋ฐ์ดํ(") ์ค ํ ์ข ๋ฅ๋ง ์ฌ์ฉํ ๊ฒฝ์ฐ print("'์๋ตํ๋ผ 1988\'์ ๋ง์ ์์ฒญ์๋ค์๊ฒ ์ฌ๋์ ๋ฐ์ ๋๋ผ๋ง์์.") print('"๋๋ ์๊ฐํ๋ค. ๊ณ ๋ก ์กด์ฌํ๋ค."๋ผ๊ณ ๋งํ๋ค.') ๋ฌธ์์ด์ ๋ค๋ฅธ ์ข ๋ฅ์ ๋ฐ์ดํ๋ฅผ ์ฌ์ฉํด์ ๊ฐ์ ๊ฒฝ์ฐ ์ค๋ฅ๊ฐ ๋ฐ์ํ์ง ์๋๋ค.
ํ๋ก๊ทธ๋๋ฐ ๊ธฐ์ด in Python | ๋ฌธ์์ด ์ฐ์ตprint("""\'์๋ตํ๋ผ 1988\'์ ๋ง์ ์์ฒญ์๋ค์๊ฒ ์ฌ๋์ ๋ฐ์ ๋๋ผ๋ง์์. ๋ฐ์นด๋ฅดํธ๋ \"๋๋ ์๊ฐํ๋ค. ๊ณ ๋ก ์กด์ฌํ๋ค.\"๋ผ๊ณ ๋งํ๋ค.""") print("์ํ \'์ ์ธ๊ณ\'์์ \"๋๋ฃจ์~\"๋ผ๋ ๋์ฌ๊ฐ ์ ํํ๋ค.") *๋ฌธ์์ด ๋ฐ์ดํ ์ถ๋ ฅ : ๋ฐ์ดํ(', ") ์์ ์ญ์ฌ๋์ฌ(\)๋ฅผ ์ฌ์ฉํ๋ค. + ์์ ๋ฐ์ดํ(') ํน์ ํฐ ๋ฐ์ดํ(") ์ค ํ ์ข ๋ฅ๋ง ์ฌ์ฉํ ๊ฒฝ์ฐ print("'์๋ตํ๋ผ 1988\'์ ๋ง์ ์์ฒญ์๋ค์๊ฒ ์ฌ๋์ ๋ฐ์ ๋๋ผ๋ง์์.") print('"๋๋ ์๊ฐํ๋ค. ๊ณ ๋ก ์กด์ฌํ๋ค."๋ผ๊ณ ๋งํ๋ค.') ๋ฌธ์์ด์ ๋ค๋ฅธ ์ข ๋ฅ์ ๋ฐ์ดํ๋ฅผ ์ฌ์ฉํด์ ๊ฐ์ ๊ฒฝ์ฐ ์ค๋ฅ๊ฐ ๋ฐ์ํ์ง ์๋๋ค.
2022.01.12 -
์ธ ์์ ๊ณฑ์ ์๋ ค์ฃผ๋ ํ๋ก๊ทธ๋จ์ ๋ง๋ค๋ ค๊ณ ํฉ๋๋ค. ํ๋ผ๋ฏธํฐ๋ก ์ ์ ๊ฐ ์ธ ๊ฐ๋ฅผ ๋ฐ๊ณ , ์ธ ์์ ๊ณฑ์ ์ถ๋ ฅํ๋ ํจ์ multiply_three_numbers๋ฅผ ๋ง๋ค์ด ๋ณด์ธ์. def multiply_three_numbers(a, b, c): print(a * b * c) # ํ ์คํธ ์ฝ๋ multiply_three_numbers(7, 3, 5) multiply_three_numbers(21, 4, 9) multiply_three_numbers(-7, 6, 3) # ์ซ์๋ฅผ ์ ๋ ฅ๋ฐ์ ์ถ๋ ฅํ๊ธฐ a = int(input()) b = int(input()) c = int(input()) def multiply_three_numbers(a, b, c): print(a * b * c) multiply_three_num..
ํ๋ก๊ทธ๋๋ฐ ๊ธฐ์ด in Python | ์ธ ์์ ๊ณฑ์ธ ์์ ๊ณฑ์ ์๋ ค์ฃผ๋ ํ๋ก๊ทธ๋จ์ ๋ง๋ค๋ ค๊ณ ํฉ๋๋ค. ํ๋ผ๋ฏธํฐ๋ก ์ ์ ๊ฐ ์ธ ๊ฐ๋ฅผ ๋ฐ๊ณ , ์ธ ์์ ๊ณฑ์ ์ถ๋ ฅํ๋ ํจ์ multiply_three_numbers๋ฅผ ๋ง๋ค์ด ๋ณด์ธ์. def multiply_three_numbers(a, b, c): print(a * b * c) # ํ ์คํธ ์ฝ๋ multiply_three_numbers(7, 3, 5) multiply_three_numbers(21, 4, 9) multiply_three_numbers(-7, 6, 3) # ์ซ์๋ฅผ ์ ๋ ฅ๋ฐ์ ์ถ๋ ฅํ๊ธฐ a = int(input()) b = int(input()) c = int(input()) def multiply_three_numbers(a, b, c): print(a * b * c) multiply_three_num..
2022.01.12 -
def cafe_mocha_recipe(): print("""1. ์ค๋น๋ ์ปต์ ์ด์ฝ ์์ค๋ฅผ ๋ฃ๋๋ค. 2. ์์คํ๋ ์๋ฅผ ์ถ์ถํ๊ณ ์์ ๋ถ์ด ์ค๋ค. 3. ์ด์ฝ ์์ค์ ์ปคํผ๋ฅผ ์ ์์ด ์ค๋ค. 4. ๊ฑฐํ๊ธฐ๋ก ์ฐ์ ๊ฑฐํ์ ๋ด๊ณ , ์์ ๋ถ์ด ์ค๋ค. 5. ์ํฌ๋ฆผ์ ์น์ด ์ค๋ค.""") cafe_mocha_recipe() cafe_mocha_recipe() *์ฌ๋ฌ ์ค ์ถ๋ ฅ : ์ฌ๋ฌ ์ค ์ฃผ์ ๋ฐฉ์๊ณผ ๋์ผํ๊ฒ """~""" ๋๋ '''~'''์ ํ์ฉํ๋ฉด ๋๋ค.
ํ๋ก๊ทธ๋๋ฐ ๊ธฐ์ด in Python | ์นดํ ๋ชจ์นด ๋ ์ํผdef cafe_mocha_recipe(): print("""1. ์ค๋น๋ ์ปต์ ์ด์ฝ ์์ค๋ฅผ ๋ฃ๋๋ค. 2. ์์คํ๋ ์๋ฅผ ์ถ์ถํ๊ณ ์์ ๋ถ์ด ์ค๋ค. 3. ์ด์ฝ ์์ค์ ์ปคํผ๋ฅผ ์ ์์ด ์ค๋ค. 4. ๊ฑฐํ๊ธฐ๋ก ์ฐ์ ๊ฑฐํ์ ๋ด๊ณ , ์์ ๋ถ์ด ์ค๋ค. 5. ์ํฌ๋ฆผ์ ์น์ด ์ค๋ค.""") cafe_mocha_recipe() cafe_mocha_recipe() *์ฌ๋ฌ ์ค ์ถ๋ ฅ : ์ฌ๋ฌ ์ค ์ฃผ์ ๋ฐฉ์๊ณผ ๋์ผํ๊ฒ """~""" ๋๋ '''~'''์ ํ์ฉํ๋ฉด ๋๋ค.
2022.01.12 -
kitkat = 190 oreos = 502 pringles = 292 twix = 135.9 cheetos = 485 print(kitkat + oreos * 2) print(cheetos * 4) print(pringles + oreos + twix) print(pringles * 3 + oreos * 2)
ํ๋ก๊ทธ๋๋ฐ ๊ธฐ์ด in Python | ์นผ๋ก๋ฆฌ ๊ณ์ฐ๊ธฐkitkat = 190 oreos = 502 pringles = 292 twix = 135.9 cheetos = 485 print(kitkat + oreos * 2) print(cheetos * 4) print(pringles + oreos + twix) print(pringles * 3 + oreos * 2)
2022.01.12 -
Python print("Hello World!")
๋ฐฑ์ค | 2557๋ฒ [Hello World]Python print("Hello World!")
2022.01.05