python第一次作业

这篇文章包含四个Python代码片段。第一个使用turtle模块绘制奥运五环;第二个计算圆柱体的面积和体积;第三个求解水加热所需的能量;第四个则涉及日期的加法运算。这些示例展示了Python在基础图形绘制、数学运算和输入输出处理方面的应用。
摘要由CSDN通过智能技术生成

1.第一个题目 画五环

import turtle as t

t.setup(700,400)

t.penup()

t.goto(-80,0)

t.pendown()

t.pencolor("blue")

t.pensize(3)

t.circle(50

)t.penup()

t.goto(0,0)

t.pendown()

t.pencolor("black")

t.pensize(3)

t.circle(50)

t.penup()

t.goto(80,0)

t.pendown()

t.pencolor("red")

t.pensize(3)

t.circle(50)

t.penup()

t.goto(-40,-80)

t.pendown()

t.pencolor("yellow")

t.pensize(3)

t.circle(50)

t.penup()

t.goto(40,-80)

t.pendown()

t.pencolor("green")

t.pensize(3)

t.circle(50)

t.done()

2.第二题demo2

r = float(input("Enter the radius of a cylinder= "))
l = float(input("Enter the length of a cylinder= "))
import math

Π = math.pi
area = r * r * Π
volume = area * l
print(f"The area is {area} ")
print(f"The volume is {volume}")

3.第三题demo5

M = float(input("Enter the amount of water in kilograms :"))
I = float(input("Enter the initial temperature :"))
F = float(input("Enter the final temperature :"))
Q = M * (F - I) * 4184
print(f"The energe needed is:{Q}")

4.第四题demo25

T = int(input("Enter today's day :"))
E = int(input("Enter the number of days elapsed since today :"))

F = (T + E % 7)

print(f"Today is {T} and the future day is {F}")
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值