Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
bellcode
/
lesson2-5_DIY1
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
ec442405
authored
Nov 03, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
6fe9c875
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
12 deletions
card.py
diy1.py
jk.py
card.py
0 → 100644
View file @
ec442405
import
turtle
screen
=
turtle
.
Screen
()
screen
.
bgcolor
(
"pink"
)
pen
=
turtle
.
Pen
()
pen
.
penup
()
pen
.
goto
(
100
,
-
100
)
pen
.
write
(
"吴晨雪,
\n
我想你了!"
,
font
=
(
"Times"
,
20
,
"normal"
))
pen
.
hideturtle
()
pen1
=
turtle
.
Pen
()
pen1
.
pensize
(
10
)
pen1
.
pencolor
(
"red"
)
pen1
.
left
(
45
)
pen1
.
forward
(
160
)
pen1
.
circle
(
80
,
180
)
#半径为80,逆时针转180度画出半圆
pen1
.
right
(
90
)
pen1
.
circle
(
80
,
180
)
pen1
.
forward
(
160
)
pen1
.
hideturtle
()
turtle
.
done
()
\ No newline at end of file
diy1.py
View file @
ec442405
player
=
input
(
"出拳:石头/剪刀/布"
)
#玩家出拳
print
(
"玩家出拳:"
+
player
)
player
=
input
(
"出拳:石头/剪刀/布"
)
#玩家出拳,并用变量player存储答案
import
random
print
(
"玩家出拳:"
+
player
)
#打印玩家出拳答案
list
=
[
"石头"
,
"剪刀"
,
"布"
]
import
random
#导入random模块
computer
=
random
.
choice
(
list
)
#计算机随机出拳
print
(
computer
)
list
=
[
"石头"
,
"剪刀"
,
"布"
]
#创建列表,存储三个参数
if
player
==
computer
:
computer
=
random
.
choice
(
list
)
#在列表中随机抽取一个元素存入变量computer中
print
(
平局
)
print
(
computer
)
#打印计算机出拳答案
#结果判断
if
player
==
computer
:
#如果玩家出拳结果等于计算机出拳结果
print
(
平局
)
#打印 平局
#添加三个条件判断
elif
(
player
==
"石头"
and
computer
==
"剪刀"
)
or
(
player
==
"剪刀"
and
computer
==
"布"
)
or
(
player
==
"布"
and
computer
==
"石头"
):
elif
(
player
==
"石头"
and
computer
==
"剪刀"
)
or
(
player
==
"剪刀"
and
computer
==
"布"
)
or
(
player
==
"布"
and
computer
==
"石头"
):
print
(
"You are win"
)
print
(
"You are win"
)
#打印玩家赢
else
:
else
:
#否则:条件都不成立
print
(
"You are a loser"
)
print
(
"You are a loser"
)
#打印玩家输
\ No newline at end of file
\ No newline at end of file
jk.py
deleted
100644 → 0
View file @
6fe9c875
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment