周末任务
Dec 10, 2024 pm 12:20 PM1.华氏度到摄氏度转换:
def fahrenheit_to_celsius(): celsius=(fahrenheit-32)*5/9 return celsius fahrenheit=float(input("Enter the Fahrenheit:")) celsius=fahrenheit_to_celsius() print("Celsius :",round(celsius,1)
登录后复制
Enter the Fahrenheit:102.3 Celsius : 39.1
登录后复制
2.摄氏度到华氏度转换:
def celsius_to_fahrenheit(): fahrenheit=celsius*9/5+32 return fahrenheit celsius=float(input("Enter the Celsius:")) fahrenheit=celsius_to_fahrenheit() print("Fahrenheit :",round(fahrenheit,1))
登录后复制
Enter the Celsius:39.1 Fahrenheit : 102.4
登录后复制
3.英尺到米换算:
def feet_to_meter(): meter=feet*0.3048 return meter feet=float(input("Enter the Feet:")) meter=feet_to_meter() print("Meter :",round(meter,3))
登录后复制
Enter the Feet:12 Meter : 3.658
登录后复制
4.求正方形的面积:
def area_of_square(): area=side**2 return area side=float(input("Enter the Side:")) area=area_of_square() print("Area :",round(area,2))
登录后复制
Enter the Side:12.3 Area : 151.29
登录后复制
5.求矩形的面积:
def area_of_rectangle(): area=length*width return area length=float(input("Enter the Length:")) width=float(input("Enter the Width:")) area=area_of_rectangle() print("Area :",round(area,2))
登录后复制
Enter the Length:13.4 Enter the Width:9.6 Area : 128.64
登录后复制
6.求圆的面积:
def area_of_circle(): area=3.14*radius**2 return area radius=float(input("Enter the Radius:")) area=area_of_circle() print("Area :",round(area,2))
登录后复制
Enter the Radius:7.2 Area : 162.78
登录后复制
7.SGD 到 INR 换算:
def sgd_to_inr(): inr=63.14*sgd return inr sgd=float(input("Enter the SGD:")) inr=sgd_to_inr() print("INR:",round(inr,2))
登录后复制
Enter the SGD:23 INR: 1452.22
登录后复制
8.新加坡时间与印度标准时间换算:
from datetime import datetime, timedelta current= datetime.now() current_time= current.strftime("%H:%M:%S") print("Singapore Time:",current_time) difference= timedelta(hours=2, minutes=30) print("Difference between Singapore and Indian Time",difference) difference=current-difference print("Indian Time:",difference.strftime("%H:%M:%S"))
登录后复制
Singapore Time: 01:32:00 Difference between Singapore and Indian Time 2:30:00 Indian Time: 23:02:00
登录后复制
9) 7, 10, 8, 11, 9, 12, 10
no=7 count=0 while count<7: print(no, end=" ") if count%2==0: no=no+3 else: no=no-2 count+=1
登录后复制
7, 10, 8, 11, 9, 12, 10
登录后复制
10) 36, 34, 30, 28, 24, 22
no=36 difference=2 while no>=22: print(no,end=" ") if difference==2: no=no-difference difference+=2 else: no=no-difference difference-=2
登录后复制
36, 34, 30, 28, 24, 22
登录后复制
11) 22, 21, 23, 22, 24, 23
no=22 difference=1 while no<25: print(no,end=" ") if difference==1: no=no-difference difference+=1 else: no=no+difference difference-=1
登录后复制
22, 21, 23, 22, 24, 23
登录后复制
12) 53, 53, 40, 40, 27, 27
no=53 difference=13 while no>=27: print(no, end=" ") print(no, end=" ") if difference==13: no=no-difference
登录后复制
53, 53, 40, 40, 27, 27
13) 21, 9, 21, 11, 21, 13, 21
odd_no=21 even_no=9 count=0 while count<7: if count%2==0: print(odd_no,end=" ") else: print(even_no,end=" ") even_no=even_no+2 count+=1
登录后复制
21, 9, 21, 11, 21, 13, 21
登录后复制
14) 3, 4, 7, 8, 11, 12
no=3 difference=1 while no<=12: print(no,end=" ") if difference==1: no=no+1 difference+=2 else: no=no+3 difference-=2
登录后复制
3, 4, 7, 8, 11, 12
登录后复制
15) 14, 28, 20, 40, 32, 64
no=14 count=0 while count<6: if count%2==0: print(no, end=" ") no=no*2 else: print(no, end=" ") no=no-8 count+=1
登录后复制
14, 28, 20, 40, 32, 64
登录后复制
以上是周末任务的详细内容。更多信息请关注PHP中文网其他相关文章!
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

热门文章
击败分裂小说需要多长时间?
3 周前
By DDD
仓库:如何复兴队友
3 周前
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island冒险:如何获得巨型种子
3 周前
By 尊渡假赌尊渡假赌尊渡假赌
公众号网页更新缓存难题:如何避免版本更新后旧缓存影响用户体验?
3 周前
By 王林
R.E.P.O.能量晶体解释及其做什么(黄色晶体)
1 周前
By 尊渡假赌尊渡假赌尊渡假赌

热门文章
击败分裂小说需要多长时间?
3 周前
By DDD
仓库:如何复兴队友
3 周前
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island冒险:如何获得巨型种子
3 周前
By 尊渡假赌尊渡假赌尊渡假赌
公众号网页更新缓存难题:如何避免版本更新后旧缓存影响用户体验?
3 周前
By 王林
R.E.P.O.能量晶体解释及其做什么(黄色晶体)
1 周前
By 尊渡假赌尊渡假赌尊渡假赌

热门文章标签

记事本++7.3.1
好用且免费的代码编辑器

SublimeText3汉化版
中文版,非常好用

禅工作室 13.0.1
功能强大的PHP集成开发环境

Dreamweaver CS6
视觉化网页开发工具

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)