โรงเรียนบัวเชดวิทยา | คิดเป็น ทำเป็น แก้ปัญหาเป็น เพื่อ ...
Python Type conversionsApril 21, 2017??????? ?????????????????????????????????????? Python ????????? built-in ???????? ?????????????????????????????????????????????????????????????? ??????? ?????????????????????????????????????????????????????????????????????????? ???? ???????????????????? String ???????? String ?????????? ??????????????????????????????? Python?????? Python ???????????? built-in ??????????????????????????????????????? ???????????????????????????????????????????????????? (???????????????????) ?????????????? ?????????int()??????????????????????? ?????????????????????? ????str()??????????????????????? ??????? String ????????????????????????????????????????????? PythonFunctionDescriptionint(x [,base])??????????? x ?????????????? base ??????? Integerlong(x [,base] )??????????? x ?????????????? base ??????? Longfloat(x)??????????? x ??????? Floating point numbercomplex(real [,im])?????????????????????????????? real ?????? imaginestr(x)??????????? x ??????? Stringrepr(x)??????????? x ??????? String expressioneval(str)????????????? Stringtuple(s)???? Sequence ??????? Tuplelist(s)???? Sequence ??????? Listset(s)???? Sequence ??????? Tupledict(d)?????????????????? Dictionaryfrozenset(s)?????????????????? Frozen setchr(x)?????????? Integer ??????? Unicode Charord(x)???? Charterer ?????????? Integerhex(x)???? Integer ??????? Hex stringoct(x)???? Integer ??????? Oct string??????? String ???????????????????????????????????????????????????????????? Python ???? ?????????????????????????????????????????????? ?????????????????????????????????????????? String ???????????? ??????????????????????????? ???????????????????????????? String ??????????????????????????????????????????? ?????????????????????# convert string to ints = input('Enter integer number: ')n = int(s)print('Type of s is ', type(s))print('Type of n is ', type(n))print('Value of n is', n)# convert string to floats2 = input('Enter floating number: ')f = float(s2)print('Type of s2 is ', type(s2))print('Type of f is ', type(f))print('Value of f is', f)?????????? ?????????????????????????????????????? ?????????????????? String ?????? Integer ????????????????????????? String ?????? Float ????????????????????? String ?????????????????????????input()???????????????????int()?????float()??????????????????? String ???? Integer ??? Float ???????? ????????????type()?????????????????????????????????????????????????? Prototype ??????Enter integer number: 10Type of s is <class 'str'>Type of n is <class 'int'>Value of n is 10Enter floating number: 3.5Type of s2 is <class 'str'>Type of f is <class 'float'>Value of f is 3.5???????????????????????????????? ???????????????????? 10 ??? 3.5 ???????? ?????????????????????? String ??????????????????????????????????????????????????????????????????????print(str(10 + 20))print(str(1.234))print(str([1, 2, 3, 4, 5, 6]))???????????????????????????????????? ??????? String ?????????????????????str()????????????????????????????????????????????????? ?????????????????????????? ?????????????? Integer Floating number ??? List ?????? String ????????301.234[1, 2, 3, 4, 5, 6]??????????????????????????????????????????????????????????? String?????????????????????????????? Python?????? Python ????????????????????????? String ????????????? ?????????????????? ?????????????????????????????????? ??????????????????????????????????????# convert integer to charprint('65 to char =', chr(65))print('70 to char =', chr(70))print('97 to char =', chr(97))print('196 to char =', chr(196))print('473 to char =', chr(473))# convert char to integersite = ''for s in site: print(s, ' = ', ord(s))????????????????????????????????????????????????????????????????? ?????????? ??????????????????????chr()?????????????? Integer ??????????????????? Unicode ??? 65 ?????????????????????????????????????????????????? (A) 70 ????????????????????????F?97 ?????????????????????????????????????????????? (a) 196 ????????????????????? 473 ?????????????????????????? ?????????? Unicode ????????????????????????????????????????????????????? ?????????ord()?????????????????????????????????? Integer ?????? ?????????? ????? String ?????????site???????????''????????????? For loop ?????????????????????????? Integer ???????????????????????? String65 to char = A70 to char = F97 to char = a196 to char = ?473 to char = ?m = 109a = 97r = 114c = 99u = 117s = 115c = 99o = 111d = 100e = 101. = 46c = 99o = 111m = 109?????????????????????????????????????????????????????chr()?????????????ord()???????????????????????????????????????? Integer ???????????????????????????????????? Sequence ??? Set?????? Python ???????????????????????? Sequence ??? Set ??????????????????????????????????????????????????? ???? ?????????? Tuple ????? List ?????????????list()??????????????????????????? List ???? Tuple ?????????????tuple()???????? ?????????dict()????????????? Mapping ??????? Dictionary ?????????????set()?????????????????? Sequence ??? ??????? Set ????????????a = list((1, 2, 3, 4, 5)) # tuple to listb = tuple([1, 2, 3, 4, 5]) # list to tuplec = set([1, 2, 3, 4, 5]) # list to setd = dict(one= 1, two = 2, three = 3) # mapping to dicte = dict([('one', 1), ('two', 2), ('three', 3)]) # iterable list to dictprint(a)print(b)print(c)print(d)print(e)?????????? ?????????????????????????????????????????? ?????????????? ???????????????????? Sequence ???????????????????????? ?????????a????????????????????? Tuple ????? List ?????????b????????????????????? List ????? Tuple ?????????????c??????????????? List ???? Set ????????????????????? ???????d???????????????????? Mapping ???? Dictionary ???????e???????? List ?????????????? Dictionary[1, 2, 3, 4, 5](1, 2, 3, 4, 5){1, 2, 3, 4, 5}{'one': 1, 'two': 2, 'three': 3}{'one': 1, 'two': 2, 'three': 3}??????????????????????????????????????????????????????????????????? Sequence ??? Set??????? ????????????????????????????????????????????????????????????? Python ?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ???????????????????????????????????????? ???? ??????? String ?????????? ??????? Integer ???? Char ????????????????????????????? Sequence ??? Set ????????????????????????????????????????????????????????????????????? ????????????????????????????????????????????????????????????? ................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- ecs 89l computer science for biologists
- informatics practices 065 cbseguess
- python murray state university
- syntax tom kleen
- โรงเรียนบัวเชดวิทยา คิดเป็น ทำเป็น แก้ปัญหาเป็น เพื่อ
- introduction
- python programming bsc it pro
- computer architecture 110
- instructor manual for introduction to computing and
- activity 1 3 4 nested branching and input answer key