β 500 ~ 1000 μ¬μ΄μ νμ ν©κ³ ꡬνκΈ° -- for
i,sum = 0, 0
for i in range(501, 1001, 2):
sum = sum + i
print ("500κ³Ό 1000 μ¬μ΄μ νμ ν©κ³ %d " % sum)
β 0 ~ 100 μ¬μ΄μ 7μ λ°°μ ν©κ³ ꡬνκΈ° -- for
i,sum = 0, 0
for i in range(0, 101, 7):
sum = sum + i
print ("7μ λ°°μ ν©κ³ %d " % sum)
β ν€λ³΄λλ‘ μ λ ₯ν κ°κΉμ§ ν©κ³ ꡬνκΈ° -- for
i,sum = 0, 0
num = 0
num = int(input("κ°μ μ
λ ₯νμΈμ"))
for i in range(1, num+ 1, 1):
sum = sum + i
print ("μ«μ ν©κ³ %d " % sum)
β ν©κ³ ꡬνκΈ° -- while
i,hap = 0,0
i=1
while i < 11 :
hap += i
i += 1
print ("1λΆν° 10κΉμ§ ν©κ³ : %d" % hap);