1.华氏度到摄氏度转换:
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 <pre class="brush:php;toolbar:false">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 <pre class="brush:php;toolbar:false">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 <pre class="brush:php;toolbar:false">21, 9, 21, 11, 21, 13, 21
14) 3, 4, 7, 8, 11, 12
no=3 difference=1 while no <pre class="brush:php;toolbar:false">3, 4, 7, 8, 11, 12
15) 14, 28, 20, 40, 32, 64
no=14 count=0 while count <pre class="brush:php;toolbar:false">14, 28, 20, 40, 32, 64
以上是周末任务的详细内容。更多信息请关注PHP中文网其他相关文章!

ForhandlinglargedatasetsinPython,useNumPyarraysforbetterperformance.1)NumPyarraysarememory-efficientandfasterfornumericaloperations.2)Avoidunnecessarytypeconversions.3)Leveragevectorizationforreducedtimecomplexity.4)Managememoryusagewithefficientdata

Inpython,ListSusedynamicMemoryAllocationWithOver-Asalose,而alenumpyArraySallaySallocateFixedMemory.1)listssallocatemoremoremoremorythanneededinentientary上,respizeTized.2)numpyarsallaysallaysallocateAllocateAllocateAlcocateExactMemoryForements,OfferingPrediCtableSageButlessemageButlesseflextlessibility。

Inpython,YouCansspecthedatatAtatatPeyFelemereModeRernSpant.1)Usenpynernrump.1)Usenpynyp.dloatp.dloatp.ploatm64,formor professisconsiscontrolatatypes。

NumPyisessentialfornumericalcomputinginPythonduetoitsspeed,memoryefficiency,andcomprehensivemathematicalfunctions.1)It'sfastbecauseitperformsoperationsinC.2)NumPyarraysaremorememory-efficientthanPythonlists.3)Itoffersawiderangeofmathematicaloperation

Contiguousmemoryallocationiscrucialforarraysbecauseitallowsforefficientandfastelementaccess.1)Itenablesconstanttimeaccess,O(1),duetodirectaddresscalculation.2)Itimprovescacheefficiencybyallowingmultipleelementfetchespercacheline.3)Itsimplifiesmemorym

SlicingaPythonlistisdoneusingthesyntaxlist[start:stop:step].Here'showitworks:1)Startistheindexofthefirstelementtoinclude.2)Stopistheindexofthefirstelementtoexclude.3)Stepistheincrementbetweenelements.It'susefulforextractingportionsoflistsandcanuseneg

numpyallowsforvariousoperationsonArrays:1)basicarithmeticlikeaddition,减法,乘法和division; 2)evationAperationssuchasmatrixmultiplication; 3)element-wiseOperations wiseOperationswithOutexpliitloops; 4)

Arresinpython,尤其是Throughnumpyandpandas,weessentialFordataAnalysis,offeringSpeedAndeffied.1)NumpyArseNable efflaysenable efficefliceHandlingAtaSetSetSetSetSetSetSetSetSetSetSetsetSetSetSetSetsopplexoperationslikemovingaverages.2)


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

Video Face Swap
使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

热工具

适用于 Eclipse 的 SAP NetWeaver 服务器适配器
将Eclipse与SAP NetWeaver应用服务器集成。

Atom编辑器mac版下载
最流行的的开源编辑器

螳螂BT
Mantis是一个易于部署的基于Web的缺陷跟踪工具,用于帮助产品缺陷跟踪。它需要PHP、MySQL和一个Web服务器。请查看我们的演示和托管服务。

SublimeText3 Linux新版
SublimeText3 Linux最新版

ZendStudio 13.5.1 Mac
功能强大的PHP集成开发环境