-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwhile.py
More file actions
62 lines (50 loc) · 1.13 KB
/
while.py
File metadata and controls
62 lines (50 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
treeHit = 0
while treeHit < 10:
treeHit += 1
print("나무를 %d번 찍음" %treeHit)
if treeHit == 10:
print("나무 쓰러짐.")
prompt = """
... 1. Add
... 2. Del
... 3. List
... 4. Quit
...
... Enter number: """
number = 0
while number != 4:
print(prompt)
number = int(input()) #사용자의 숫자 입력을 받아들이는 것.
# while문 강제로 빠져나가기 break
'''
# coffee.py
coffee = 10
while True:
money = int(input("돈을 넣어 주세요: "))
if money == 300:
print("커피를 줍니다.")
coffee = coffee -1
elif money > 300:
print("거스름돈 %d를 주고 커피를 줍니다." % (money -300))
coffee = coffee -1
else:
print("돈을 다시 돌려주고 커피를 주지 않습니다.")
print("남은 커피의 양은 %d개 입니다." % coffee)
if coffee == 0:
print("커피가 다 떨어졌습니다. 판매를 중지 합니다.")
break
'''
# while문의 맨 처음으로 돌아가기
'''
>>> a = 0
>>> while a < 10:
... a = a + 1
... if a % 2 == 0: continue
... print(a)
...
1
3
5
7
9
'''