Skip to content

Commit eb555ef

Browse files
committed
simple game
1 parent dc30daf commit eb555ef

File tree

4 files changed

+63
-0
lines changed

4 files changed

+63
-0
lines changed

taiyangxue/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
- [why](https://github.com/JustDoPython/python-examples/tree/master/taiyangxue/why) : 练那么多,为啥还不会编程
1919
- [rate](https://github.com/JustDoPython/python-examples/tree/master/taiyangxue/rate-of-return) : 做时间的朋友,必须知道收益咋算
2020
- [blockchain](https://github.com/JustDoPython/python-examples/tree/master/taiyangxue/blockchain) : 比特币涨疯了,区块链是什么鬼?
21+
- [simple game](https://github.com/JustDoPython/python-examples/tree/master/taiyangxue/simple-game) : 与其说教,不如一起写个游戏
2122

2223
---
2324

taiyangxue/simple-game/v1.py

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import random
2+
3+
num = random.randint(0,10)
4+
5+
while(True):
6+
n = input("请输入:")
7+
n = int(n)
8+
if num == n:
9+
print("你赢啦!!!\n\n")
10+
break
11+
elif num < n:
12+
print("大")
13+
else:
14+
print("小")

taiyangxue/simple-game/v2.py

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import random
2+
3+
anger_face = ["ಠ_ಠ","ノಠ_ಠノ","(¬_¬)", "(┳◇┳)","(◔ д◔)","(ʘдʘ╬)","(눈_눈)","-`д´-"]
4+
5+
num = random.randint(0,10)
6+
while(True):
7+
n = input("请输入:")
8+
if not n.isdecimal():
9+
print(random.choice(anger_face))
10+
continue
11+
12+
n = int(n)
13+
if num == n:
14+
print("你赢啦!!!\n\n")
15+
break
16+
elif num < n:
17+
print("大")
18+
else:
19+
print("小")

taiyangxue/simple-game/v3.py

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import random
2+
3+
anger_face = ["ಠ_ಠ","ノಠ_ಠノ","(¬_¬)", "(┳◇┳)","(◔ д◔)","(ʘдʘ╬)","(눈_눈)","-`д´-","😲","😱","😧"]
4+
5+
def game():
6+
print("( ^∀^)/欢迎\( ^∀^)")
7+
num = random.randint(0,10)
8+
9+
while(True):
10+
n = input(">>>>:")
11+
if not n.isdecimal():
12+
print(random.choice(anger_face))
13+
continue
14+
15+
n = int(n)
16+
if num == n:
17+
print("✌ ('ω')")
18+
break
19+
elif num < n:
20+
print("大")
21+
else:
22+
print("小")
23+
24+
while(True):
25+
game()
26+
c = input("再来一把 (y)/n?")
27+
if c == "n":
28+
print("(ToT)/~~~")
29+
break

0 commit comments

Comments
 (0)