① Python編程:三角形計算器
whileTrue:
a,b,c=eval(input('輸入三角形三邊長,以逗號分隔:'))
ifa+b>canda+c>bandb+c>a:
break;
print('輸入的三邊長不合法,請重新輸入')
print('周長為...')
print('面積為...')
② python璁$畻鍣
python璁$畻鍣ㄥ疄鐜幫細
wx.TextCtrl錛堟枃鏈杈撳叆鎺т歡錛夛紝榪欎釜浣滀負璁$畻鍣ㄧ殑鏄劇ず灞忥紝鐐瑰嚮鏁板瓧鏃剁敤AppendText鏂規硶灝嗘暟瀛楁坊鍔犺嚦鏂囨湰鏈灝撅紝瑕佸彇鍑烘暟瀛楁椂鐢℅etValue鏂規硶錛岀偣鍑昏繍綆楃︽椂瑕佸皢鏂囨湰妗嗕腑鐨勬暟瀛楁竻絀猴紙鍏堝瓨鍌錛夌敤Clear鏂規硶鐒跺悗榪樻湁灝嗘搷浣滅︿繚瀛橈紝鐐瑰嚮絳夊彿鍚庤佸皢絎浜屼釜鎿嶄綔鏁板瓨鍌錛岀劧鍚庣敤int鏂規硶灝嗗瓧絎︿覆杞鎹涓烘暟瀛楋紝璁$畻鍚庣敤SetValue鏂規硶灝嗙粨鏋滈佸叆鏂囨湰妗嗭紝鍏蜂綋浠g爜濡備笅錛
importwx
#beginwxGlade:extracode
#endwxGlade
classMyFrame(wx.Frame):
def__init__(self,*args,**kwds):
#beginwxGlade:MyFrame.__init__
kwds["style"]=wx.DEFAULT_FRAME_STYLE
wx.Frame.__init__(self,*args,**kwds)
self.text_ctrl_1=wx.TextCtrl(self,-1,"",style=wx.TE_READONLY)
self.button_37=wx.Button(self,-1,"1")
self.button_38=wx.Button(self,-1,"2")
self.button_39=wx.Button(self,-1,"3")
self.button_40=wx.Button(self,-1,"+")
self.button_41=wx.Button(self,-1,"4")
self.button_42=wx.Button(self,-1,"5")
self.button_43=wx.Button(self,-1,"6")
self.button_44=wx.Button(self,-1,"-")
self.button_46=wx.Button(self,-1,"7")
self.button_45=wx.Button(self,-1,"8")
self.button_47=wx.Button(self,-1,"9")
self.button_48=wx.Button(self,-1,"x")
self.button_49=wx.Button(self,-1,"C")
self.button_50=wx.Button(self,-1,"0")
self.button_51=wx.Button(self,-1,"=")
self.button_52=wx.Button(self,-1,"/")
self.__set_properties()
self.__do_layout()
self.Bind(wx.EVT_BUTTON,self.bu1,self.button_37)
self.Bind(wx.EVT_BUTTON,self.bu2,self.button_38)
self.Bind(wx.EVT_BUTTON,self.bu3,self.button_39)
self.Bind(wx.EVT_BUTTON,self.bu_plus,self.button_40)
self.Bind(wx.EVT_BUTTON,self.bu4,self.button_41)
self.Bind(wx.EVT_BUTTON,self.bu5,self.button_42)
self.Bind(wx.EVT_BUTTON,self.bu6,self.button_43)
self.Bind(wx.EVT_BUTTON,self.bu_min,self.button_44)
self.Bind(wx.EVT_BUTTON,self.bu7,self.button_46)
self.Bind(wx.EVT_BUTTON,self.bu8,self.button_45)
self.Bind(wx.EVT_BUTTON,self.bu9,self.button_47)
self.Bind(wx.EVT_BUTTON,self.bu_mul,self.button_48)
self.Bind(wx.EVT_BUTTON,self.bu_clear,self.button_49)
self.Bind(wx.EVT_BUTTON,self.bu0,self.button_50)
self.Bind(wx.EVT_BUTTON,self.bu_result,self.button_51)
self.Bind(wx.EVT_BUTTON,self.bu_chu,self.button_52)
#endwxGlade
self.Show(True)
def__set_properties(self):
#beginwxGlade:MyFrame.__set_properties
self.SetTitle("PythonCalculaterbyCYG")
self.text_ctrl_1.SetMinSize((400,50))
self.button_37.SetMinSize((100,50))
self.button_38.SetMinSize((100,50))
self.button_39.SetMinSize((100,50))
self.button_40.SetMinSize((100,50))
self.button_41.SetMinSize((100,50))
self.button_42.SetMinSize((100,50))
self.button_43.SetMinSize((100,50))
self.button_44.SetMinSize((100,50))
self.button_46.SetMinSize((100,50))
self.button_45.SetMinSize((100,50))
self.button_47.SetMinSize((100,50))
self.button_48.SetMinSize((100,50))
self.button_49.SetMinSize((100,50))
self.button_50.SetMinSize((100,50))
self.button_51.SetMinSize((100,50))
self.button_52.SetMinSize((100,50))
#endwxGlade
def__do_layout(self):
#beginwxGlade:MyFrame.__do_layout
sizer_2=wx.BoxSizer(wx.VERTICAL)
sizer_3=wx.BoxSizer(wx.VERTICAL)
grid_sizer_1=wx.GridSizer(4,4,0,0)
sizer_3.Add(self.text_ctrl_1,0,0,0)
grid_sizer_1.Add(self.button_37,0,0,0)
grid_sizer_1.Add(self.button_38,0,0,0)
grid_sizer_1.Add(self.button_39,0,0,0)
grid_sizer_1.Add(self.button_40,0,0,0)
grid_sizer_1.Add(self.button_41,0,0,0)
grid_sizer_1.Add(self.button_42,0,0,0)
grid_sizer_1.Add(self.button_43,0,0,0)
grid_sizer_1.Add(self.button_44,0,0,0)
grid_sizer_1.Add(self.button_46,0,0,0)
grid_sizer_1.Add(self.button_45,0,0,0)
grid_sizer_1.Add(self.button_47,0,0,0)
grid_sizer_1.Add(self.button_48,0,0,0)
grid_sizer_1.Add(self.button_49,0,0,0)
grid_sizer_1.Add(self.button_50,0,0,0)
grid_sizer_1.Add(self.button_51,0,0,0)
grid_sizer_1.Add(self.button_52,0,0,0)
sizer_3.Add(grid_sizer_1,1,wx.EXPAND,0)
sizer_2.Add(sizer_3,1,wx.EXPAND,0)
self.SetSizer(sizer_2)
sizer_2.Fit(self)
self.Layout()
#endwxGlade
defbu1(self,event):#wxGlade:MyFrame.<event_handler>
self.text_ctrl_1.AppendText("1")
event.Skip()
defbu2(self,event):#wxGlade:MyFrame.<event_handler>
self.text_ctrl_1.AppendText("2")
event.Skip()
defbu3(self,event):#wxGlade:MyFrame.<event_handler>
self.text_ctrl_1.AppendText("3")
event.Skip()
defbu_plus(self,event):#wxGlade:MyFrame.<event_handler>
self.num1=self.text_ctrl_1.GetValue()
self.op="+"
self.text_ctrl_1.Clear()
event.Skip()
defbu4(self,event):#wxGlade:MyFrame.<event_handler>
self.text_ctrl_1.AppendText("4")
event.Skip()
defbu5(self,event):#wxGlade:MyFrame.<event_handler>
self.text_ctrl_1.AppendText("5")
event.Skip()
defbu6(self,event):#wxGlade:MyFrame.<event_handler>
self.text_ctrl_1.AppendText("6")
event.Skip()
defbu_min(self,event):#wxGlade:MyFrame.<event_handler>
self.num1=self.text_ctrl_1.GetValue()
self.op="-"
self.text_ctrl_1.Clear()
event.Skip()
defbu7(self,event):#wxGlade:MyFrame.<event_handler>
self.text_ctrl_1.AppendText("7")
event.Skip()
defbu8(self,event):#wxGlade:MyFrame.<event_handler>
self.text_ctrl_1.AppendText("8")
event.Skip()
defbu9(self,event):#wxGlade:MyFrame.<event_handler>
self.text_ctrl_1.AppendText("9")
event.Skip()
defbu_mul(self,event):#wxGlade:MyFrame.<event_handler>
self.num1=self.text_ctrl_1.GetValue()
self.op="x"
self.text_ctrl_1.Clear()
event.Skip()
defbu_clear(self,event):#wxGlade:MyFrame.<event_handler>
self.text_ctrl_1.Clear()
event.Skip()
defbu0(self,event):#wxGlade:MyFrame.<event_handler>
self.text_ctrl_1.AppendText("0")
event.Skip()
defbu_chu(self,event):#wxGlade:MyFrame.<event_handler>
self.num1=self.text_ctrl_1.GetValue()
self.op="/"
self.text_ctrl_1.Clear()
event.Skip()
defbu_result(self,event):#wxGlade:MyFrame.<event_handler>
self.num2=self.text_ctrl_1.GetValue()
num1=int(self.num1)
num2=int(self.num2)
ifself.op=="+":
self.text_ctrl_1.SetValue(str(num1+num2))
elifself.op=="-":
self.text_ctrl_1.SetValue(str(num1-num2))
elifself.op=="x":
self.text_ctrl_1.SetValue(str(num1*num2))
elifself.op=="/":
self.text_ctrl_1.SetValue(str(num1/num2))
event.Skip()
#endofclassMyFrame
if__name__=="__main__":
app=wx.App(False)
myframe=MyFrame(None)
app.MainLoop()
③ 如何用手機編程Python
手機下載APP
手機分為智能手機(Smart phone) [2] 和非智能手機(Feature phone),一般智能手機的性能比非智能手機要好,但是非智能手機比智能手機性能穩定,大多數非智能手機和智能手機使用英國ARM公司架構的CPU。智能手機的主頻較高,運行速度快,處理程序任務更快速,日常更加的方便(例如:諾基亞n81主頻有369兆赫茲);而非智能手機的主頻則比較低,運行速度也比較慢(例如:諾基亞5000主頻就是50兆赫茲)。
智能手機(Smart phone),是指像個人計算機一樣,具有獨立的操作系統,大多數是大屏機,而且是電容式觸摸屏,也有部分是電阻式觸摸屏,功能強大實用性高。可以由用戶自行安裝包括游戲等第三方服務商提供的程序,通過此類程序來不斷對手機的功能進行擴充,並可以通過移動通訊網路來實現無線網路接入的這樣一類手機的總稱」。從廣義上說,智能手機除了具備手機的通話功能外,還具備了PDA的大部分功能,特別是個人信息管理以及基於無線數據通信的瀏覽器和電子郵件功能。智能手機為用戶提供了足夠的屏幕尺寸和帶寬,既方便隨身攜帶,又為軟體運行和內容服務提供了廣闊的舞台。很多增值業務可以就此展開,如:股票、新聞、天氣、交通、商品、應用程序下載、音樂圖片,游戲下載等等
手機類型顧名思義就是指手機的外在類型,比較常用的分類是把手機分為直板式、折疊式(單屏、雙屏)、滑蓋式、旋轉式、側滑式等幾類。
要翻開蓋才可見到主顯示器或按鍵,且只有一個屏幕,則這種手機被稱為單屏翻蓋手機。市場上還推出了雙屏翻蓋手機,即在翻蓋上有另一個副顯示屏,這個屏幕通常不大,一般能顯示時間、信號、電池、來電號碼等功能。屏幕比較小,一般在2.2英寸或1.8英寸,處理器較慢。