Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
lesson11_2
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
707e6582
authored
Jul 22, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
caf46cda
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
5 deletions
__pycache__/func.cpython-37.pyc
demo1.py
dmeo.py
func.py
__pycache__/func.cpython-37.pyc
View file @
707e6582
No preview for this file type
demo1.py
0 → 100644
View file @
707e6582
def
sum
(
x
,
y
):
z
=
x
+
y
return
z
a
=
sum
(
10
,
20
)
print
(
"两数之和为:"
,
a
)
\ No newline at end of file
dmeo.py
View file @
707e6582
...
...
@@ -4,4 +4,4 @@ data = func.new_input() # 模块名称.函数名称()
result
=
func
.
amont
(
data
)
print
(
"总
金额
是:"
,
result
)
print
(
"总
分数
是:"
,
result
)
func.py
View file @
707e6582
...
...
@@ -12,10 +12,11 @@ def new_input():
print
(
"请输入整数!"
)
else
:
total
.
append
(
int
(
unit
))
print
(
total
)
#
print(total)
return
total
# return 返回total给调用
# 调用函数
price_list
=
new_input
()
# price_list 是接收函数返回值
#price_list = new_input() # price_list 是接收函数返回值
#print(price_list)
def
amont
(
money
):
# 形式参数只是在定义函数时写上
sm
=
0
...
...
@@ -23,8 +24,8 @@ def amont(money): # 形式参数只是在定义函数时写上
sm
+=
i
return
sm
result
=
amont
(
price_list
)
# 调整用函数时,要根据"形式参数"个数来赋值"实际参数"
print
(
"总金额是:"
,
result
)
#
result = amont(price_list) # 调整用函数时,要根据"形式参数"个数来赋值"实际参数"
#
print("总金额是:",result)
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