2021. 2. 1. 21:27ㆍpython
#while 문
'''
while <조건문>: # 조건문이 부적확 할 시 무한루프에 빠져버린다.
수행할 문장1
수행할 문장2
'''
# treeHit =0
# while treeHit <10:
# treeHit += 1
# print("나무를%d번 찍었습니다.\n" % treeHit)
# if treeHit==10:
# print("나무가 넘어갑니다.\n")
# else:
# print("아직 나무가 넘어가지 않습니다.\n")
# num=0
# prompt = '1.add' '2.del' '3.list' '4.quit' '5.name'
# while num != 4:
# num=int(input())
# if num>=5:
# break
# coffee=5
# money=500
# while money:
# coffee -=1
# print("남은 커피의 양은{}입니다.".format(coffee))
# if not coffee:
# print("커피는 다 소진 되었어")
# a = 0
# while a<10:
# print("1==",a)
# a+=1
# print("2==",a)
# if a % 2==0:
# break
# coffee = 10
# havemoney = 1500
# while havemoney:
# coffee -= 1
# havemoney -= 300
# print("남은 커피의 양은{}입니다.".format(coffee))
# print("남은 돈의 양은 %d" % havemoney)
# coffee =10
# while True:
# money=int(input("가지고 있는 돈은?"))
# if money ==300:
# print("가지고있는 돈은 %d이며 커피한잔 드립니다." % money)
# coffee -=1
# print("남은 커피의 수량은 %d잔 입니다"% coffee)
# elif money>300:
# print("거스름돈 %d를 드립니다." % (money-300))
# coffee -= 1
# print("남은 커피의 수량은 %d잔 입니다" % coffee)
# else:
# print("입력받은 돈이 %d이므로 돈을 반환하고 커피는 안 드립ㄴ디ㅏ." %money)
# print("남은 커피의 수량은 %d잔 입니다" % coffee)
# if not coffee:
# print("커피가 모두 소진 되었습니다." % coffee)
# break
# 구구단을 출력하는 소스
# for x in range(1,10):
# for y in range(1,10):
# print(x, "X",y,"=",x*y)
# 1부터 1000까지 숫자 중 3의 배수의 합을 구하는 소스
i ,sum = 1, 0
while i < 1000:
if i%3==0:
sum+=i
i+=1
print("%d" % sum)