Created
October 29, 2020 16:24
-
-
Save EdwinTai/b477f2039bb6b8de27623fda08d46a9d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
#真值表 and 只有TT才是True | |
print(True & True) | |
print(True & False) | |
print(False & True) | |
print(False & False) | |
#真值表 or 有T就是True | |
print(True | True) | |
print(True | False) | |
print(False | True) | |
print(False | False) | |
#直值表 not 反轉 | |
print(not True) | |
print(not False) | |
#浮點數 float complex decimal | |
#e 科學符號10的次方 | |
print(10e3) | |
print(10e-3) | |
#常數pi | |
print(math.pi) | |
#向下轉成最接近整數 | |
print(math.floor(-3.6)) | |
#向上轉成最接近整數 | |
print(math.ceil(-3.6)) | |
#四捨五入 | |
print(round(-3.6,0)) | |
#複數.real 取實數 .imag取虛數 | |
num = 58-3.14j | |
print(num.real) | |
print(num.imag) | |
#虛數正負號轉換 | |
print(num.conjugate()) | |
#decimal https://kirin.idv.tw/python-decimal-module-tutorial/ 千萬別用float decimal only | |
from decimal import Decimal | |
a = Decimal(1.15) | |
print(a) | |
b = Decimal('1.15') | |
print(b) | |
#引數就是輸入值,可以有很多種字串、float等等,不過為了避免"意外",請用字串 | |
c = 1.15 | |
d = Decimal(str(c)) | |
print(d) | |
#字串單引號 雙引號包起來 | |
print('字串') | |
print("字串") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment