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
e9f63d83
authored
Nov 22, 2020
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
23cf2c63
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
22 deletions
__pycache__/函数返回值.cpython-37.pyc
函数返回值.py
总和.py
计算.py
__pycache__/函数返回值.cpython-37.pyc
View file @
e9f63d83
No preview for this file type
函数返回值.py
View file @
e9f63d83
def
d
iancan
():
def
d
iancan
():
def
diancan
():
def
diancan
():
total
=
[]
total
=
[]
while
True
:
while
True
:
unit
=
input
(
'请输入(q退出):'
)
unit
=
input
(
"请输入:"
)
if
unit
==
'q'
:
if
unit
==
'q'
:
break
break
else
:
else
:
try
:
try
:
unit
=
int
(
unit
)
unit
=
int
(
unit
)
except
:
except
:
print
(
"
请重新输入一个数字
"
)
print
(
"
输入的不是价格
"
)
else
:
else
:
total
.
append
(
unit
)
total
.
append
(
unit
)
return
total
return
total
def
sum
(
b
):
# 计算价钱的函数 b是形参 也就是上边刚才输入的列表
def
sum
(
money
):
w
=
0
#计算累加和的变量
count
=
0
for
i
in
b
:
#遍历b列表
for
i
in
money
:
w
+=
i
#依次计算列表中的价格
count
=
count
+
i
return
w
#返回w
return
count
a
=
diancan
()
#a是diancan函数中的列表
a
=
diancan
()
e
=
sum
(
a
)
#给sum函数传入实参a也就是价格列表
b
=
sum
(
a
)
print
(
e
)
#输出总共的价格
print
(
b
)
\ No newline at end of file
总和.py
View file @
e9f63d83
import
返回
import
time
import
返回
import
time
a
=
返回
.
diancan
()
i
=
0
b
=
返回
.
sum
()
while
True
:
\ No newline at end of file
i
+=
1
print
(
i
)
time
.
sleep
(
1
)
计算.py
View file @
e9f63d83
import
返回
import
函数返回值
#只能导入以中英文命名的文件
import
返回
import
函数返回值
#只能导入以中英文命名的文件
a
=
返回
.
diancan
()
a
=
函数返回值
.
diancan
()
b
=
返回
.
sum
()
b
=
函数返回值
.
sum
()
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