夜色资源站www国产在线资源,国产偷窥熟妇高潮呻吟,潮湿的心动漫在线观看免费未删减,欧美日韩国产成人精品

當前位置:考試網  > 試卷庫  > 計算機類  > 等級考試  > 計算機二級  > Python語言程序設計  >  請用 Python 語言編寫一個簡易的計算器程序。
試題預覽

請用 Python 語言編寫一個簡易的計算器程序。

查看答案
收藏
糾錯
正確答案:

from tkinter import *

reset=True

def buttonCallBack(event):

global label

global reset

num=event.widget['text']

if num=='C':

label['text']="0"

return

if num in "=":

label['text']=str(eval(label['text']))

reset=True

return

s=label['text']

if s=='0' or reset==True:

s=""

reset=False

label['text']=s+num #主窗口

root=Tk() root.wm_title(" 計算器 ") #顯示欄 1 label=Label(root,text="0",background="white",anchor="e")

label['width']=35

label['height']=2

label.grid(row=1,columnspan=4,sticky=W) #按鈕

showText="789/456*123-0.C+"

for i in range(4):

for j in range(4):

b=Button(root,text=showText[i*4+j],width=7)

b.grid(row=i+2,column=j)

b.bind("",buttonCallBack) showText="()"

for i in range(2):www.jb51.net

b=Button(root,text=showText[i],width=7)

b.grid(row=6,column=2+i)

b.bind("",buttonCallBack) b=Button(root,text="=")

b.grid(row=6,columnspan=2,sticky="we")

b.bind("",buttonCallBack)

root.mainloop()

答案解析:

暫無解析

你可能感興趣的試題

為了提高測試的效率,應該

Python語言有哪些運算符?請列表說明它們各自的運算優先級。

下面不屬于軟件工程的3個要素的是

請簡述Python中類方法、實例方法、靜態方法各自的區別?并簡述它們各自的用途。

在E-R圖中,哪個選項是用來表示聯系的圖形

掃一掃,手機做題