(将摄氏温度转化为华氏温度)编写一个从控制台读取摄氏温度并将它转变为华氏温度并予以显示的程序。

(将摄氏温度转化为华氏温度)编写一个从控制台读取摄氏温度并将它转变为华氏温度并予以显示的程序。转换公式如下所示。
fahrenheit = (9 / 5) * celsius + 32
这里是这个程序的示例运行。
在这里插入图片描述

celsius = float(input("Enter a degree in Celsius:"))
fahrenheit = (9/5)*celsius + 32
print("%s Celsius is %s Fahrenheit"%(celsius,fahrenheit))

(计算圆柱体的体积)编写一个读取圆柱的半径和高并利用下面的公式计算圆柱体底面积和体积的程序:
area = radius * radius * 3.14
volume = area * length
这里是示例运行。
在这里插入图片描述

r,h = eval(input("Enter the radius and length of a cylinder:"))
area =r * r *3.14
volume = area * h
print("The area is %.4f"%area)
print("The volume is %.f"%volume)

(对一个整数中的各位数字求和)编写一个程序,读取一个0到1000之间的整数并计算它各位数字之和。例如:如果一个整数是932,那么它各位数字之和就是14。(提示:使用%来提取数字,使用//运算符来去除掉被提取的数字。例如:932%10=2而932//10=93。)这里是一个示例运行。
在这里插入图片描述

s = int(input("Enter a number between 0 and 1000:"))
a = s//100
b = s//10%10
c = s%10
sum = a+b+c
print("The sum of the digits is",sum)

(计算年数和天数)编写一个程序,提示用户输入分钟数(例如:1 000 000 ),然后将分钟转换为年数和天数并显示的程序。为了简单起见,假定一年有365天。这里是一个示例运行。
在这里插入图片描述

a = int(input("Enter the number of minutes:"))
year = int(a/60/24/365)
day = int((a-year*60*24*365)/60/24)
print("%s minutes is approximately %s years and %s days"%(a,year,day))

(科学:计算能量)编写一个程序计算将水从初始温度加热到最终温度所需的能量。你的程序应该提示用户输入以千克计算的水量以及水的初始温度和最终温度。计算能量的公式是
0= M* (fina1Temperature - initia1Temperature) * 4184
这里的M是按千克计的水量,温度为摄氏温度.热量Q以焦耳计。这里是一个示例运行。
在这里插入图片描述

M = float(input("Enter the amount of water in kilograms:"))
a = float(input("Enter the initial temperature:"))
b = float(input("Enter the final temperature:"))
Q = M * (b -<
  • 2
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值