๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

Algorithm/Codeup

(5)
[Codeup] ์ฝ”๋“œ์—… ๊ธฐ์ดˆ 100์ œ Python #6052 ~ #6060 #6052 - ์ •์ˆ˜ ์ž…๋ ฅ๋ฐ›์•„ ์ฐธ ๊ฑฐ์ง“ ํ‰๊ฐ€ํ•˜๊ธฐ a = int(input()) print(bool(a)) ๋ถ„์„ > bool(a)๋ฅผ ์ ์œผ๋ฉด 0์€ False๋กœ ๊ทธ ์ด์™ธ์˜ ๊ฐ’๋“ค์€ True๊ฐ€ ๋œ๋‹ค. #6053 - ์ฐธ ๊ฑฐ์ง“ ๋ฐ”๊พธ๊ธฐ a = bool(int(input())) print(not a) ๋ถ„์„ > ์œ„์˜ a์˜ ๊ฒฝ์šฐ input -> int -> bool ์ˆœ์œผ๋กœ ์ฒ˜๋ฆฌ๋˜๋ฉฐ ์ฐธ ๋˜๋Š” ๊ฑฐ์ง“์˜ ๋…ผ๋ฆฌ๊ฐ’์„ ์—ญ(๋ฐ˜๋Œ€)์œผ๋กœ ๋ฐ”๊พธ๊ธฐ ์œ„ํ•ด์„œ not ์˜ˆ์•ฝ์–ด(reserved word, keyword)๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค. #6054 - ๋‘˜๋‹ค ์ฐธ์ผ ๊ฒฝ์šฐ๋งŒ ์ฐธ ์ถœ๋ ฅํ•˜๊ธฐ a,b = input().split() print(bool(int(a)) and bool(int(b))) ๋ถ„์„ > and ์˜ˆ์•ฝ์–ด๋Š” ์ฃผ์–ด์ง„ ๋‘ ๋ถˆ ๊ฐ’์ด ๋ชจ๋‘ True ์ผ ๋•Œ์—๋งŒ Tru..
[Codeup] ์ฝ”๋“œ์—… ๊ธฐ์ดˆ 100์ œ Python #6041 ~ #6051 #6041 - ์ •์ˆ˜ 2๊ฐœ ์ž…๋ ฅ๋ฐ›์•„ ๋‚˜๋ˆˆ ๋‚˜๋จธ์ง€ ๊ณ„์‚ฐํ•˜๊ธฐ a, b = map(int,input().split(" ")) print(a%b) #6042 - ์‹ค์ˆ˜ 1๊ฐœ ์ž…๋ ฅ๋ฐ›์•„ ์†Œ์ˆซ์  ์ดํ•˜ ์ž๋ฆฌ ๋ณ€ํ™˜ํ•˜๊ธฐ a = float(input()) print(format(a,".2f")) ๋ถ„์„ > format(a, ".2f") ๋Š” ์†Œ์ˆซ์  ์ดํ•˜ ๋‘๋ฒˆ์งธ ์ž๋ฆฌ๊นŒ์ง€ ๋‚˜ํƒ€๋‚ผ ๋•Œ ์ด์šฉํ•œ๋‹ค. #6043 - ์‹ค์ˆ˜ 2๊ฐœ ์ž…๋ ฅ๋ฐ›์•„ ๋‚˜๋ˆˆ ๊ฒฐ๊ณผ ๊ณ„์‚ฐํ•˜๊ธฐ a, b = map(float, input().split(" ")) print(format((a/b),".3f")) #6044 - ์ •์ˆ˜ 2๊ฐœ ์ž…๋ ฅ๋ฐ›์•„ ์ž๋™ ๊ณ„์‚ฐํ•˜๊ธฐ a,b = map(int,input().split(" ")) print(a+b) print(a-b) print(a*b) prin..
[Codeup] ์ฝ”๋“œ์—… ๊ธฐ์ดˆ 100์ œ Phython #6031 ~ #6040 ๋ณดํ˜ธ๋˜์–ด ์žˆ๋Š” ๊ธ€์ž…๋‹ˆ๋‹ค.
[Codeup] ์ฝ”๋“œ์—… ๊ธฐ์ดˆ 100์ œ Phython #6021 ~ #6030 #6021 - ๋‹จ์–ด 1๊ฐœ ์ž…๋ ฅ๋ฐ›์•„ ๋‚˜๋ˆ„์–ด ์ถœ๋ ฅํ•˜๊ธฐ s = input() print(s[0]) print(s[1]) print(s[2]) print(s[3]) print(s[4]) ๋ถ„์„ > ๋ฌธ์ž์—ด๋„ index๋ฅผ ํ™œ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค. #6022 - ์—ฐ์›”์ผ ์ž…๋ ฅ๋ฐ›์•„ ๋‚˜๋ˆ„์–ด ์ถœ๋ ฅํ•˜๊ธฐ s = input() print(s[0:2], end=" ") print(s[2:4], end=" ") print(s[4:6], end=" ") #6023 - ์—ฐ์›”์ผ ์ž…๋ ฅ๋ฐ›์•„ ๋‚˜๋ˆ„์–ด ์ถœ๋ ฅํ•˜๊ธฐ a,b,c = input().split(":") print(b) #6024 - ๋‹จ์–ด 2๊ฐœ ์ž…๋ ฅ๋ฐ›์•„ ์ด์–ด ๋ถ™์ด๊ธฐ a,b = input().split(" ") print(a+b) #6025 - ์ •์ˆ˜ 2๊ฐœ ์ž…๋ ฅ๋ฐ›์•„ ํ•ฉ ๊ณ„์‚ฐํ•˜๊ธฐ a,b = map(int,..
[Codeup] ์ฝ”๋“œ์—… ๊ธฐ์ดˆ 100์ œ Python #6001 ~ #6020 ํŒŒ์ด์ฌ์— ๋Œ€ํ•œ ๊ธฐ์ดˆ ๋ฌธ๋ฒ• ๊ฐ๊ฐ์„ ๊ธฐ๋ฅด๊ธฐ ์œ„ํ•ด์„œ ๋งค์ผ ์ฝ”๋“œ์—… ๊ธฐ์ดˆ 100์ œ๋ฅผ ํ’€์–ด๋‚˜๊ฐ€๊ธฐ๋กœ ํ–ˆ๋‹ค. ์‰ฌ์šด ๋ฌธ์ œ๋”๋ผ๋„ ๋†“์น˜์ง€ ์•Š๊ธฐ ์œ„ํ•ด ๋‚ด๊ฐ€ ํ‘ผ ๋ชจ๋“  ๋ฌธ์ œ ํ’€์ด์™€ ํ•ด์„ค ๋‹ต์•ˆ์„ ๋ถ„์„ํ•ด ๋ณด๊ธฐ๋กœ ํ•œ๋‹ค. #6001 - Hello ์ถœ๋ ฅํ•˜๊ธฐ print("Hello") #6002 - Hello World ์ถœ๋ ฅํ•˜๊ธฐ print("Hello","World") #6003 - ๋‘ ์ค„์— ๊ฑธ์ณ Hello World ์ถœ๋ ฅํ•˜๊ธฐ print("Hello") print("World") #6004 - ์ž‘์€ ๋”ฐ์˜ดํ‘œ ์ถœ๋ ฅํ•˜๊ธฐ print("'Hello'") #6005 - ํฐ ๋”ฐ์˜ดํ‘œ ์ถœ๋ ฅํ•˜๊ธฐ print('"Hello World"') #6006 - ํŠน์ˆ˜๋ฌธ์ž ์ถœ๋ ฅํ•˜๊ธฐ (์˜ค๋‹ต) print("\"!@#$%^&*()\'") # output: "!@#$%^&*()..