python温度转换程序代码_摄氏温度到华氏温度的转换图形用户界面程序python

编写一个GUI程序,将摄氏温度转换为华氏温度。用户应该能够输入摄氏温度,点击一个按钮,然后看到等效的华氏温度。使用以下公式进行转换:

F=(9/5)C+32

F是华氏温度,C是摄氏温度。在

以下是我所拥有的,但当我运行它时,什么都不会发生:#import

#main function

from tkinter import *

def main():

root=Tk()

root.title("Some GUI")

root.geometry("400x700")

#someothersting=""

someotherstring=""

#enter Celcius

L1=Label(root,text="Enter a Celcius temperature.")

E1=Entry(root,textvariable=someotherstring)

somebutton=Button(root, text="Total", command=lambda: convert(E1.get()))

somebutton.pack()

E1.pack()

L1.pack()

root.mainloop()#main loop

#convert Celcius to Fahrenheit

def convert(somestring):

if somestring != "":

cel=int(somestring)

far=(9/5*(cel))+32

print(far)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值