python作业_小学生python作业参考

1。乘法表

test2():

for i in range(1, 10):

print()

for j in range(1, i+1):

#print("%d*%d=%d" % (j, i, j*i),end='\t')

print("{}*{}={}".format(i,j,i*j), end="\t")

if __name__ == '__main__':

test2()

2。斐波那契数列

# 获取用户输入数据

nterms = int(input("你需要几项?"))

# 第一和第二项

n1 = 1

n2 = 1

count = 2

# 判断输入的值是否合法

if nterms <= 0:

print("请输入一个正整数。")

elif nterms == 1:

print("斐波那契数列:")

print(n1)

else:

print("斐波那契数列:")

print(n1,",",n2,end=" , ")

while count < nterms:

nth = n1 + n2

print(nth,end=" , ")

# 更新值

n1 = n2

n2 = nth

count += 1

3。微信智能回复机器人

4。python绘制五角星-turtle

import turtle #导入turtle库包

turtle.fillcolor("red") #填充颜色

turtle.begin_fill() #开始画,类似起笔

count = 1 #计时器,用于计录次数

while count <= 5: #控制绘制次数

turtle.forward(100) #画笔绘制的方向,向前移动指定的距离

turtle.right(144) #向右转144度

count += 1 #循环绘制

turtle.end_fill() #完成填充图片的绘制。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值