Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
lesson11_1
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
4bed2ad7
authored
Nov 08, 2020
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
a526bd91
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
9 deletions
__pycache__/函数返回值.cpython-37.pyc
func.py
函数返回值.py
计算价格.py
__pycache__/函数返回值.cpython-37.pyc
0 → 100644
View file @
4bed2ad7
File added
func.py
View file @
4bed2ad7
def
charu
():
total
=
[]
while
True
:
unit
=
input
(
"请输入:"
)
if
unit
==
'q'
:
break
else
:
unit
=
int
(
unit
)
total
.
append
(
unit
)
total
=
[]
while
True
:
unit
=
input
(
"请输入:"
)
if
unit
==
'q'
:
break
else
:
unit
=
int
(
unit
)
total
.
append
(
unit
)
return
total
#返回total
...
...
函数返回值.py
0 → 100644
View file @
4bed2ad7
def
diancan
():
def
diancan
():
total
=
[]
while
True
:
unit
=
input
(
'请输入(q退出):'
)
if
unit
==
'q'
:
break
else
:
try
:
unit
=
int
(
unit
)
except
:
print
(
"请重新输入一个数字"
)
else
:
total
.
append
(
unit
)
return
total
def
sum
(
b
):
# 计算价钱的函数 b是形参 也就是上边刚才输入的列表
w
=
0
#计算累加和的变量
for
i
in
b
:
#遍历b列表
w
+=
i
#依次计算列表中的价格
return
w
#返回w
a
=
diancan
()
#a是diancan函数中的列表
e
=
sum
(
a
)
#给sum函数传入实参a也就是价格列表
print
(
e
)
#输出总共的价格
计算价格.py
0 → 100644
View file @
4bed2ad7
import
函数返回值
import
函数返回值
a
=
函数返回值
.
diancan
()
b
=
函数返回值
.
sum
()
print
(
b
)
\ 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