์กฐ๊ฑด๋ฌธ
if money>=3000:
print("ํ์ ํ๊ณ ๊ฐ๋ผ")
else:
print("๊ฑธ์ด๊ฐ๋ผ")
>> ๊ฑธ์ด๊ฐ๋ผ
pocket = ['paper', 'cellphone', 'money']
if 'money' in pocket:
print("ํ์๋ฅผ ํ๊ณ ๊ฐ๋ผ")
else:
pass #์๋ฌด ์ผ๋ ์ผ์ด๋์ง ์๊ฒ ์ค์
>> ํ์๋ฅผ ํ๊ณ ๊ฐ๋ผ
--> pass: ์๋ฌด ์ผ๋ ํ์ง ์๊ฒ ์ค์ !
Message = "success" if score>=60 else "failure"
๋ฐ๋ณต๋ฌธ
coffee = 10
money = 300
while money:
print("๋์ ๋ฐ์์ผ๋ ์ปคํผ๋ฅผ ์ค๋๋ค.")
coffee = coffee - 1
print("๋จ์ ์ปคํผ์ ์์ %d๊ฐ์
๋๋ค." %coffee)
if not coffe:
print("์ปคํผ๊ฐ ๋ค ๋จ์ด์ก์ต๋๋ค. ํ๋งค๋ฅผ ์ค์งํฉ๋๋ค.")
break;
a = [(1,2), (3,4), (5,6)]
for (first, last) in a:
print(first+last)
>>
3
7
11
sum = 0
for i in range(1,11)
print(i, end=" ")
sum = sum+i
print(sum)
>> 55
a = [1,2,3,4]
result = [num*3 for num in a]
print(Result)
>> [3,6,9,12]