import random
import tkinter
import tkinter.messagebox
defb_clicked()
:if name_entry.get()==
'':tkinter.messagebox.showerror(title=
'error'
, message=
'請輸入使用者名字'
)else
: cin_name = name_entry.get(
)try
: text_check =
''.join(j for j in age_entry.get(
)if j in
'0123456789'
) cin_age =
int(text_check)
text_check =
''.join(j for j in weight_entry.get(
)if j in
'0123456789.'
) cin_weight =
float
(text_check)
text_check =
''.join(j for j in high_entry.get(
)if j in
'0123456789.'
) cin_high =
float
(text_check)
except valueerror:
tkinter.messagebox.showerror(title=
'error'
, message=
'請輸入數字'
) pi = bmi(cin_name, cin_age, cin_weight, cin_high)
pi.search_get(
)class
bmi:
def__init__
(self, name, age, weight, high)
: self.name = name
self.age = age
self.weight = weight
self.high = high
self.bmi = self.weight / self.high / self.high
if self.bmi <
18.5
: self.status =
"健康狀況:偏瘦。"
elif
18.5
<= self.bmi <24:
self.status =
"健康狀況:正常。"
elif
24<= self.bmi <30:
self.status =
"健康狀況:偏胖。"
elif self.bmi >30:
self.status =
"健康狀況:肥胖。"
defsearch_get
(self)
: label2[
'text']=
"當前使用者為{},年齡為{},體重為{},身高為{},\nbmi值為,{}"
.format
(self.name, self.age,
self.weight, self.high, self.bmi,
self.status)
if __name__ ==
"__main__"
: n =
int(random.random()*
50+1)
i =0 window = tkinter.tk(
) window.title(
'bmi計算器'
) window.geometry(
'500x300'
) label1 = tkinter.label(window, text=
'bmi計算器'
, font=
('arial',12
), width=
30, height=2)
label1.place(x=
110, y=
0, anchor=
'nw'
) button1 = tkinter.button(window, text=
'開始計算'
, font=
('arial',12
), width=
20, height=
1, command=b_clicked)
button1.place(x=
150, y=
50, anchor=
'nw'
) label2 = tkinter.label(window, text=
'請輸入相關資訊'
, bg=
'green'
, font=
('arial',12
), width=
50, height=3)
label2.pack(side=
'bottom'
) name_entry = tkinter.entry(window, width=
7, show=
none
) name_entry.place(x=
220, y=
90, anchor=
'nw'
) age_entry = tkinter.entry(window, width=
7, show=
none
) age_entry.place(x=
220, y=
120, anchor=
'nw'
) weight_entry = tkinter.entry(window, width=
7, show=
none
) weight_entry.place(x=
220, y=
150, anchor=
'nw'
) high_entry = tkinter.entry(window, width=
7, show=
none
) high_entry.place(x=
220, y=
180, anchor=
'nw'
) label3 = tkinter.label(window, text=
'姓名:'
, font=
('arial',10
), width=
4, height=1)
label3.place(x=
180, y=
90, anchor=
'nw'
) label4 = tkinter.label(window, text=
'年齡:'
, font=
('arial',10
), width=
4, height=1)
label4.place(x=
180, y=
120, anchor=
'nw'
) label4 = tkinter.label(window, text=
'體重:'
, font=
('arial',10
), width=
4, height=1)
label4.place(x=
180, y=
150, anchor=
'nw'
) label4 = tkinter.label(window, text=
'身高:'
, font=
('arial',10
), width=
4, height=1)
label4.place(x=
180, y=
180, anchor=
'nw'
) window.mainloop(
)
資料視覺化 什麼是資料視覺化
資料對應的英文單詞是data,從資訊獲取的角度看,資料是對目標觀察和記錄的結果,是現實世界中的時間 地點 事件 其他物件或概念的描述。不同學者對資料的作用也給出不同的定義,大致分為以下3類 視覺化對應的兩個英文單詞 visualize和visualization。visualize是動詞,描述 生成...
視覺化建模
中科永聯高階技術培訓中心 www.itisedu.com 視覺化建模 visual modeling 是利用圍繞現實想法組織模型的一種思考問題的方法。模型對於了解問題 與專案相關的每個人 客戶 行業專家 分析師 設計者等 溝通 模仿企業流程 準備文件 設計程式和資料庫來說都是有用的。建模促進了對需求...
卷積視覺化
影象卷積操作的應用沒有嚴格的數學推導,即沒有數學推導表明每一層究竟表示什麼。為了了解卷積神經網路中每一層與原有影象的對應關係,文章visualizing and understanding convolutional networks通過反向卷積的方式實現了該過程。那具體如何操作的呢?得到的h1與真...