Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
lesson11_5
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
6d5fc702
authored
Jun 10, 2023
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
7150d945
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
25 deletions
__pycache__/func.cpython-37.pyc
func.py
guess.py
__pycache__/func.cpython-37.pyc
View file @
6d5fc702
No preview for this file type
func.py
View file @
6d5fc702
def
new_input
():
total
=
[]
while
True
:
print
(
"-"
*
40
)
unit
=
input
(
"请输入:"
)
if
unit
==
'q'
:
break
try
:
unit
=
int
(
unit
)
except
:
print
(
"输入有误,请重新输入数字价格!!"
)
continue
else
:
total
.
append
(
unit
)
return
total
def
sum
(
money
):
count
=
0
for
i
in
money
:
count
=
count
+
i
return
count
# result=new_input()
# print("输入菜品价格是:",result)
# sumprice=sum(result)
# print("你今天消费:",sumprice,"根金条")
\ No newline at end of file
guess.py
0 → 100644
View file @
6d5fc702
import
turtle
import
random
screen
=
turtle
.
Screen
()
pen
=
turtle
.
Pen
()
list
=
[]
for
i
in
range
(
1
,
101
):
list
.
append
(
i
)
num
=
random
.
choice
(
list
)
while
True
:
guessnum
=
screen
.
textinput
(
"猜数字"
,
"请输入1-101之间的数:"
)
pen
.
clear
()
if
guessnum
==
"q"
:
exit
()
if
"只因"
in
guessnum
or
"两年半"
in
guessnum
:
pen
.
write
(
"小黑子露出鸡脚"
,
font
=
(
"Times"
,
25
,
"normal"
))
#print("小黑子露出鸡脚")
continue
try
:
guessnum
=
int
(
guessnum
)
except
:
pen
.
write
(
"请输入数字"
,
font
=
(
"Times"
,
25
,
"normal"
))
#print("请输入数字")
continue
if
guessnum
==
num
:
pen
.
write
(
"恭喜你猜对了"
,
font
=
(
"Times"
,
25
,
"normal"
))
#print("恭喜你猜对了")
break
elif
guessnum
<
1
or
guessnum
>
100
:
pen
.
write
(
"不在范围内"
,
font
=
(
"Times"
,
25
,
"normal"
))
print
(
"不在范围内"
)
continue
elif
guessnum
<
num
:
pen
.
write
(
"往大了猜"
,
font
=
(
"Times"
,
25
,
"normal"
))
print
(
"往大了猜"
)
elif
guessnum
>
num
:
pen
.
write
(
"往小了猜"
,
font
=
(
"Times"
,
25
,
"normal"
))
print
(
"往小了猜"
)
\ No newline at end of file
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