2012年9月4日 星期二

Python Numeral Operation Practice

'''
Created on 2012/9/4
Third Python program - numeral
@author: Andy Liu
'''
import math
if __name__ == '__main__':
    print(3) #int
    print(math.pi,int(math.pi)) #real
    n=1.1+2.2j #complex
    p=n+2 #complex add 
    print(n,n.real,n.imag) #complex,real,imagine
    print(p)
    # ??
    print(1.0-0.8,(1.0-0.8),(1.0-0.8).__repr__())# repr function
    print(1.0-0.8,(1.0-0.8))
    import decimal
    print((decimal.Decimal('1.0')-decimal.Decimal('0.8')))
    print((decimal.Decimal(1.0)-decimal.Decimal(0.8)))
    print(1.0-0.8)
    print((1.0-0.8))   
    # ??
    print(oct(10),hex(10),bin(10))#numeral conversion
    print(2**8)
    print(10/3,10//3,10%3)
執行結果
3
(3.141592653589793, 3)
((1.1+2.2j), 1.1, 2.2)
(3.1+2.2j)
(0.19999999999999996, 0.19999999999999996, '0.19999999999999996')
(0.19999999999999996, 0.19999999999999996)
0.2
0.1999999999999999555910790150
0.2
0.2
('012', '0xa', '0b1010')
256
(3, 3, 1)

2012年9月3日 星期一

Python String Operation Practice

'''
Created on 2012/8/31
Second Python program - String 
@author: Andy Liu
'''

if __name__ == '__main__': 
    str1='Hello '
    str2="World !"
    str3=str1+str2 #combine
    str4=str1*2 #double
    str5=str4.replace(" Hello"," World !") #replace string
    print(str1)
    print(str2)
    print(str3)
    print(str4)
    print(str5)
    print "Hello" in str4
    print "!" in str4
    print(len(str4)) #string length
    print(str3.split(" ")) #split String
    print(dir(str1)) # string type character
    pass
執行結果
Hello 
World !
Hello World !
Hello Hello 
Hello World ! 
True
False
12
['Hello', 'World', '!']
['__add__', '__class__', '__contains__', '__delattr__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getnewargs__', '__getslice__', '__gt__', '__hash__', '__init__', '__le__', '__len__', '__lt__', '__mod__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmod__', '__rmul__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '_formatter_field_name_split', '_formatter_parser', 'capitalize', 'center', 'count', 'decode', 'encode', 'endswith', 'expandtabs', 'find', 'format', 'index', 'isalnum', 'isalpha', 'isdigit', 'islower', 'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip', 'partition', 'replace', 'rfind', 'rindex', 'rjust', 'rpartition', 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title', 'translate', 'upper', 'zfill']

2012年9月2日 星期日

康乃爾筆記法

康乃爾筆記法是由康乃爾大學的名譽教授 Walter Pauk 所創,整個頁面(參見下圖)可以分為三大部分,其中 Note Talking Area 是做筆記的地方,而 Cue Column 是讓你做整理、回顧與復習用的地方,Summaries 則是總結的地方,其本上由整個格式設計已預留好的空白,讓你能夠反復思考註記,且易於回顧,增進學習的效果。基本上康乃爾筆記格式可拿任一筆記本自行畫出,如果覺得的太麻煩,大創(DAISO)也有賣現成的筆記本,如果想要自已印出來使用,可以到 American Digest 網站上下載,網站上有三個檔案:



1. CornellNoteSystem.pdf :說明如何使用康乃爾筆記法,附有範例。




2. CornellNotesPlain.pdf:為康乃爾筆記法空白格式。



3.CornellNotesGraph.pdf :為康乃爾筆記法背景為方格圖格式,便於筆記做圖用。

[Excel]如何創建自定義函數

在 Excel 內建函式中找不到自已想要的函式怎麼辦?事實上我們可以自已建一個,以下是一個簡單的Excel自定義函數示例,用於將民國年轉為西元: Function 民國轉西元(x As Double) As Double     民國轉西元 = x + 1911 End Func...