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