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
667f2bef
authored
Jul 23, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
8353f20c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
4 deletions
__pycache__/func.cpython-37.pyc
demo.py
demo1.py
func.py
__pycache__/func.cpython-37.pyc
0 → 100644
View file @
667f2bef
File added
demo.py
0 → 100644
View file @
667f2bef
def
add
(
x
,
y
):
z
=
x
+
y
#print(z)
return
z
#通过return把z返回给调用函数
result
=
add
(
10
,
20
)
# 调用函数并使用变量result来接收返回值
print
(
"两数之和是:"
,
result
)
\ No newline at end of file
demo1.py
0 → 100644
View file @
667f2bef
import
func
data
=
func
.
new_input
()
score
=
func
.
sum
(
data
)
print
(
"总得分是:"
,
score
)
\ No newline at end of file
func.py
View file @
667f2bef
def
new_input
():
# 定义函数
def
new_input
():
# 定义
输入价格
函数
total
=
[]
while
True
:
unit
=
input
(
"请输入:"
)
...
...
@@ -11,7 +11,20 @@ def new_input(): # 定义函数
print
(
"请输入一个整数!"
)
else
:
total
.
append
(
unit
)
print
(
total
)
#print(total)
return
total
# 调用函数(运行函数)
new_input
()
\ No newline at end of file
# price = new_input()
# print("价格列表:",price)
# 累加函数
def
sum
(
amount
):
amount_sum
=
0
for
i
in
amount
:
amount_sum
+=
i
return
amount_sum
# print("总金额是:",sum(price))
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