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
bcdc309a
authored
Jul 19, 2021
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
cf9e63fa
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
15 deletions
__pycache__/func.cpython-37.pyc
func.py
__pycache__/func.cpython-37.pyc
View file @
bcdc309a
No preview for this file type
func.py
View file @
bcdc309a
def
xin_cai
():
total
=
[]
#建一个空列表,来存储每个菜的价格
while
True
:
#进入循环,让顾客可以点不止一个菜
unit
=
input
(
"请输入:"
)
#让顾客在后面写上菜价
if
unit
==
'q'
:
#如果点完菜,按q推出
break
#结束循环
else
:
try
:
unit
=
float
(
unit
)
except
:
print
(
"请输入一个价格!"
)
#在输入的价格不符合时,告诉顾客输入的不是价格,让顾客再输入一个正常的价格
else
:
total
.
append
(
unit
)
return
total
#返回total一个数
def
sum
(
money
):
zong
=
0
#先让zong赋值为零
for
i
in
money
:
zong
+=
i
return
zong
#返回zong一个数
price
=
xin_cai
()
num
=
sum
(
price
)
print
(
"您好,您用餐总价是"
,
num
,
"元。"
)
#告诉顾客用餐的总价
\ No newline at end of file
print
(
"您好,您用餐总价是"
,
num
,
"元。"
)
\ 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