张嘉译的作业

2023-12-18 23:23:42

文章目录


1.

import turtle

# 颜色
turtle.pencolor("red")
# 线条粗细
turtle.pensize(6)


#面向方向移动 180
turtle.forward(180)
#逆时针旋转 120
turtle.left(120)

turtle.forward(80)
turtle.left(60)

turtle.forward(100)
turtle.left(60)
turtle.forward(80)

turtle.done()

2.


num=1
count=0
while num<=100:
    # 开始循环
    sum=0
    for n in range(1,num+1):
        sum += n
    # print("sum=",sum,"    count=",count)
    count += sum;
    # print(count)
    num +=1
print(count)

3.


num=1
count=0
while num<=10:
    # 开始循环
    sum=0
    for n in range(1,num+1):
        sum += n
    # print("sum=",sum,"    count=",count)
    count += sum;
    # print(count)
    num +=1
print(count)

4.



# -*- coding:utf-8 -*-
num = input("请输入数字 :  ")
num =int(num)
if num % 400 == 0 or (num % 4 ==0 and num % 100 != 0):
    print("Yes")
else:
    print("No")

5.

for i in range(1,10):
    for j in range(1,i+1):
        print(i,"*",j, "=",i*j,end='\t')
    print()

6.

num1=0
num2=1
index=3
print(0)
print(1)
while index <=20:
    # 开始循环
    newNum=num1+num2;
    num1=num2;
    num2=newNum
    print(newNum)
    index += 1



文章来源:https://blog.csdn.net/qq_44627608/article/details/135072137
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。