Commit d6a6bc4c by BellCodeEditor

auto save

parent 5265ca6b
#请将下⾯代码封装成能返回两个数之和的函数
#s=x+y
def func(x,y):
s=x+y
return s
result=func(3,4)
print(result)
\ No newline at end of file
#定义⼀个函数,能返回两个数之间的最⼤值
def func(x,y):
if x>y:
return x
else:
return y
result=func(5,8)
print(result)
\ No newline at end of file
# 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
......@@ -3,4 +3,5 @@
# 和你的小伙伴用列表讲讲温酒斩华雄的故事,上半集,并完成下面的挑战:
#这时还是无名小卒的关羽上前请战,请从b列表中删掉“关羽”,用三种方法哦。
b=['袁术','夏侯惇','曹操','关羽']
\ No newline at end of file
b=['袁术','夏侯惇','曹操','关羽']
print(b)
\ No newline at end of file
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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment