Javascript개발자의 눈으로 python 들여다보기

4,126 views

Published on

python basic

0 Comments
22 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
4,126
On SlideShare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
53
Comments
0
Likes
22
Embeds 0
No embeds

No notes for slide

Javascript개발자의 눈으로 python 들여다보기

  1. 1. Javascript개발자가 바라보는Python기초
  2. 2. pythonhigh-level programming languageinterpretedobject orientedsimpleeasy to learntutorial,,, libraries...
  3. 3. python 으로 할 수 있는 일웹 어플리케이션 프레임웍,CGIUI 어플리케이션,시스템프로그래밍,서버,
  4. 4. python의 철학 중,‘Complex is better than complicated’counter = 0while counter < 5: for i in xrange(5): print counter print i counter += 1
  5. 5. 실행print “hello world”python hello.py
  6. 6. ; 과 {,}block구분을 위한 brace나 (syntaxError),statement의 끝을 의미하는 semicolon 사용을 권장하지 않음def calculateFactorial(number { if number == 0{ return 1; }else { result = number * calculateFactorial(number-1); return result; }}
  7. 7. indentpython interpreter는 들여쓰기를 기준으로 해석.def calculateFactorial(number): if number == 0: return 1 else : result = number * calculateFactorial(number-1) return result
  8. 8. 변수count = 1000 //integerpi = 3.14 //floating pointname =“jisu” //stringtype(count) //typeof 와 비슷
  9. 9. global 변수 count = 1;count = 1; def addCount() :def addCount() : global count count +=1 count +=1print count print count>>> 1 >>> 1
  10. 10. 연산자 javascript python "abc"+"233" "abc"+"233" ->“abc233” ->“abc233”
  11. 11. 함수 javascript pythonfunction def aaa() :aaa() { print(1) alert(1);}
  12. 12. listst = [‘a’, ‘b’ , ‘c’]del t[1]print t[‘a’, ‘c’]
  13. 13. listst = ‘pining for the fjords’.split()print t[pinging, for, the, jfords]>>> print t[1:3][for, the]
  14. 14. dictionariesvar obj = {“name”: “jisu”, “age”:20}>>> dict = {}>>> dict["name"] = "jisu">>> print dict{name: jisu}
  15. 15. dictionaries열거하기dict = {“name”: “jisu”, “age”:20}>>> for name in dict:... print(dict[name])
  16. 16. python code.ex)def calculateFactorial(number): if number == 0: return 1 else : result = number * calculateFactorial(number-1) return resultdef main(): inputVal = input("input number : ") if inputVal: result = calculateFactorial(int(inputVal)) print(result)main()
  17. 17. comment 여러줄 """ getErrorData 메서드는 객체 형태의 에러데이터를 반환한다 @ method getErrorData @ param {void} @ return {Dictionaries} , [count, detailErrorMsg2....] } """ <원래는 triple-quotes는 multiline string 을 변수에 담으려고 사용된 형태임> 한줄 # test 함수입니다 def getErrorData(self): ....
  18. 18. OOPclass based, not prototype-based class testClass: def __init__(self,name): self.name = name정의 def getName(self): return self.name def setReName(self, addText): self.name = self.name + addText elp = testClass("jslounge")호출 print (elp.getName()); elp.setReName("is forever") print (elp.getName());
  19. 19. modulesjslounge.pydef print_func(arg): print(arg)다른 파일에서 jslounge.py에서 정의한 print_func()함수를 사용하고 싶다면?
  20. 20. modulesjslounge.pydef print_func(arg): print(arg)call.pyimport jslounge or from jslounge import print_funcjslounge.print_func(“4th”) print_func(“4th”)
  21. 21. End;-D

×