Python 練習(xí)實(shí)例48 Python 100例 題目:數(shù)字比較。 程序分析:無(wú) 程序源代碼: #!/usr/bin/python # -*- coding: UTF-8 -*- if __name__ == '__main__': i = 10 j = 20 if i > j: print '%d 大于 %d' % (i,j) elif i == j: print '%d 等于 %d' % (i,j) elif i &l...
http://www.o2fo.com/python/python-exercise-example48.htmlPython 練習(xí)實(shí)例58 Python 100例 題目:畫(huà)圖,學(xué)用rectangle畫(huà)方形?! ?程序分析: rectangle(int left, int top, int right, int bottom) 參數(shù)說(shuō)明:(left ,top )為矩形的左上坐標(biāo),(right,bottom)為矩形的右下坐標(biāo),兩者可確定一個(gè)矩形的大小 程序...
http://www.o2fo.com/python/python-exercise-example58.htmlPython 練習(xí)實(shí)例39 Python 100例 題目:有一個(gè)已經(jīng)排好序的數(shù)組?,F(xiàn)輸入一個(gè)數(shù),要求按原來(lái)的規(guī)律將它插入數(shù)組中。 程序分析:首先判斷此數(shù)是否大于最后一個(gè)數(shù),然后再考慮插入中間的數(shù)的情況,插入后此元素之后的數(shù),依次...
http://www.o2fo.com/python/python-exercise-example39.htmlPython 練習(xí)實(shí)例49 Python 100例 題目:使用lambda來(lái)創(chuàng)建匿名函數(shù)。 程序分析:無(wú) 程序源代碼: #!/usr/bin/python # -*- coding: UTF-8 -*- MAXIMUM = lambda x,y : (x > y) * x + (x < y) * y MINIMUM = lambda x,y : (x > y) * y + (x < y) * x if __name__ == '__mai...
http://www.o2fo.com/python/python-exercise-example49.htmlPython 練習(xí)實(shí)例40 Python 100例 題目:將一個(gè)數(shù)組逆序輸出。 程序分析:用第一個(gè)與最后一個(gè)交換。 程序源代碼: #!/usr/bin/python # -*- coding: UTF-8 -*- if __name__ == '__main__': a = [9,6,5,4,1] N = len(a) print a for i in range(len(a) / 2): a[i],a[N - ...
http://www.o2fo.com/python/python-exercise-example40.htmlPython 練習(xí)實(shí)例50 Python 100例 題目:輸出一個(gè)隨機(jī)數(shù)。 程序分析:使用 random 模塊。 程序源代碼: #!/usr/bin/python # -*- coding: UTF-8 -*- import random #生成 10 到 20 之間的隨機(jī)數(shù) print random.uniform(10, 20) 以上實(shí)例輸出結(jié)果為: 14.4012371357 Py...
http://www.o2fo.com/python/python-exercise-example50.htmlPython 練習(xí)實(shí)例60 Python 100例 題目:計(jì)算字符串長(zhǎng)度?! ?程序分析:無(wú)。 程序源代碼: #!/usr/bin/python # -*- coding: UTF-8 -*- sStr1 = 'strlen' print len(sStr1) 以上實(shí)例輸出結(jié)果為: 6 Python 100例
http://www.o2fo.com/python/python-exercise-example60.htmlPython 練習(xí)實(shí)例41 Python 100例 題目:模仿靜態(tài)變量的用法。 程序分析:無(wú)。 程序源代碼: #!/usr/bin/python # -*- coding: UTF-8 -*- def varfunc(): var = 0 print 'var = %d' % var var += 1 if __name__ == '__main__': for i in range(3): varfunc() # 類的屬...
http://www.o2fo.com/python/python-exercise-example41.htmlPython 練習(xí)實(shí)例51 Python 100例 題目:學(xué)習(xí)使用按位與 & 。 程序分析:0&0=0; 0&1=0; 1&0=0; 1&1=1。 程序源代碼: #!/usr/bin/python # -*- coding: UTF-8 -*- if __name__ == '__main__': a = 077 b = a & 3 print 'a & b = %d' % b b &= 7 print 'a & b = %d' % ...
http://www.o2fo.com/python/python-exercise-example51.htmlPython 練習(xí)實(shí)例61 Python 100例 題目:打印出楊輝三角形(要求打印出10行如下圖)?! ?程序分析:無(wú)。 程序源代碼: #!/usr/bin/python # -*- coding: UTF-8 -*- if __name__ == '__main__': a = [] for i in range(10): a.append([]) for j in range(10): a[i].ap...
http://www.o2fo.com/python/python-exercise-example61.html抱歉,暫時(shí)沒(méi)有相關(guān)的微課
w3cschool 建議您:
抱歉,暫時(shí)沒(méi)有相關(guān)的視頻課程
w3cschool 建議您:
抱歉,暫時(shí)沒(méi)有相關(guān)的教程
w3cschool 建議您:
Python 練習(xí)實(shí)例48 Python 100例 題目:數(shù)字比較。 程序分析:無(wú) 程序源代碼: #!/usr/bin/python # -*- coding: UTF-8 -*- if __name__ == '__main__': i = 10 j = 20 if i > j: print '%d 大于 %d' % (i,j) elif i == j: print '%d 等于 %d' % (i,j) elif i &l...
http://www.o2fo.com/python/python-exercise-example48.htmlPython 練習(xí)實(shí)例58 Python 100例 題目:畫(huà)圖,學(xué)用rectangle畫(huà)方形?! ?程序分析: rectangle(int left, int top, int right, int bottom) 參數(shù)說(shuō)明:(left ,top )為矩形的左上坐標(biāo),(right,bottom)為矩形的右下坐標(biāo),兩者可確定一個(gè)矩形的大小 程序...
http://www.o2fo.com/python/python-exercise-example58.htmlPython 練習(xí)實(shí)例39 Python 100例 題目:有一個(gè)已經(jīng)排好序的數(shù)組?,F(xiàn)輸入一個(gè)數(shù),要求按原來(lái)的規(guī)律將它插入數(shù)組中。 程序分析:首先判斷此數(shù)是否大于最后一個(gè)數(shù),然后再考慮插入中間的數(shù)的情況,插入后此元素之后的數(shù),依次...
http://www.o2fo.com/python/python-exercise-example39.htmlPython 練習(xí)實(shí)例49 Python 100例 題目:使用lambda來(lái)創(chuàng)建匿名函數(shù)。 程序分析:無(wú) 程序源代碼: #!/usr/bin/python # -*- coding: UTF-8 -*- MAXIMUM = lambda x,y : (x > y) * x + (x < y) * y MINIMUM = lambda x,y : (x > y) * y + (x < y) * x if __name__ == '__mai...
http://www.o2fo.com/python/python-exercise-example49.htmlPython 練習(xí)實(shí)例40 Python 100例 題目:將一個(gè)數(shù)組逆序輸出。 程序分析:用第一個(gè)與最后一個(gè)交換。 程序源代碼: #!/usr/bin/python # -*- coding: UTF-8 -*- if __name__ == '__main__': a = [9,6,5,4,1] N = len(a) print a for i in range(len(a) / 2): a[i],a[N - ...
http://www.o2fo.com/python/python-exercise-example40.htmlPython 練習(xí)實(shí)例50 Python 100例 題目:輸出一個(gè)隨機(jī)數(shù)。 程序分析:使用 random 模塊。 程序源代碼: #!/usr/bin/python # -*- coding: UTF-8 -*- import random #生成 10 到 20 之間的隨機(jī)數(shù) print random.uniform(10, 20) 以上實(shí)例輸出結(jié)果為: 14.4012371357 Py...
http://www.o2fo.com/python/python-exercise-example50.htmlPython 練習(xí)實(shí)例60 Python 100例 題目:計(jì)算字符串長(zhǎng)度?! ?程序分析:無(wú)。 程序源代碼: #!/usr/bin/python # -*- coding: UTF-8 -*- sStr1 = 'strlen' print len(sStr1) 以上實(shí)例輸出結(jié)果為: 6 Python 100例
http://www.o2fo.com/python/python-exercise-example60.htmlPython 練習(xí)實(shí)例41 Python 100例 題目:模仿靜態(tài)變量的用法。 程序分析:無(wú)。 程序源代碼: #!/usr/bin/python # -*- coding: UTF-8 -*- def varfunc(): var = 0 print 'var = %d' % var var += 1 if __name__ == '__main__': for i in range(3): varfunc() # 類的屬...
http://www.o2fo.com/python/python-exercise-example41.htmlPython 練習(xí)實(shí)例51 Python 100例 題目:學(xué)習(xí)使用按位與 & 。 程序分析:0&0=0; 0&1=0; 1&0=0; 1&1=1。 程序源代碼: #!/usr/bin/python # -*- coding: UTF-8 -*- if __name__ == '__main__': a = 077 b = a & 3 print 'a & b = %d' % b b &= 7 print 'a & b = %d' % ...
http://www.o2fo.com/python/python-exercise-example51.htmlPython 練習(xí)實(shí)例61 Python 100例 題目:打印出楊輝三角形(要求打印出10行如下圖)?! ?程序分析:無(wú)。 程序源代碼: #!/usr/bin/python # -*- coding: UTF-8 -*- if __name__ == '__main__': a = [] for i in range(10): a.append([]) for j in range(10): a[i].ap...
http://www.o2fo.com/python/python-exercise-example61.html抱歉,暫時(shí)沒(méi)有相關(guān)的文章
w3cschool 建議您: