Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
bellcode
/
lesson6-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
d6a6bc4c
authored
Jun 05, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
5265ca6b
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
45 additions
and
2 deletions
demo1.py
demo2.py
demo3.py
diy.py
lx.py
demo1.py
0 → 100644
View file @
d6a6bc4c
#请将下⾯代码封装成能返回两个数之和的函数
#s=x+y
def
func
(
x
,
y
):
s
=
x
+
y
return
s
result
=
func
(
3
,
4
)
print
(
result
)
\ No newline at end of file
demo2.py
0 → 100644
View file @
d6a6bc4c
#定义⼀个函数,能返回两个数之间的最⼤值
def
func
(
x
,
y
):
if
x
>
y
:
return
x
else
:
return
y
result
=
func
(
5
,
8
)
print
(
result
)
\ No newline at end of file
demo3.py
0 → 100644
View file @
d6a6bc4c
# 4、请定义⼀个函数,当传⼊⼀个正整数,能计算出0到这个数之和,例如:
# 当传⼊3,能计算出0+1+2+3之和;
# 当传⼊5,能计算出0+1+2+3+4+5之和
def
func
(
n
):
count
=
0
for
i
in
range
(
n
+
1
):
count
+=
i
return
count
result
=
func
(
4
)
print
(
result
)
\ No newline at end of file
diy.py
View file @
d6a6bc4c
...
...
@@ -3,4 +3,5 @@
# 和你的小伙伴用列表讲讲温酒斩华雄的故事,上半集,并完成下面的挑战:
#这时还是无名小卒的关羽上前请战,请从b列表中删掉“关羽”,用三种方法哦。
b
=
[
'袁术'
,
'夏侯惇'
,
'曹操'
,
'关羽'
]
\ No newline at end of file
b
=
[
'袁术'
,
'夏侯惇'
,
'曹操'
,
'关羽'
]
print
(
b
)
\ No newline at end of file
lx.py
0 → 100644
View file @
d6a6bc4c
import
turtle
pen
=
turtle
.
Pen
()
pen
.
left
(
45
)
pen
.
circle
(
50
,
180
)
pen
.
home
()
pen
.
left
(
45
)
pen
.
fd
(
100
)
pen
.
left
(
90
)
pen
.
circle
(
50
,
180
)
pen
.
hideturtle
()
turtle
.
done
()
\ 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