def add(a,b):
return a+b
print(add(1,2))
print(add('abc', 'def'))
print(add([1, 2, 3], [4, 5, 6]))
3 abcdef [1, 2, 3, 4, 5, 6]
a=[12, 'abcde', 4+2j, [3,4,5]]
a.append('add')
print(a);
[12, 'abcde', (4+2j), [3, 4, 5], 'add']
print(4+5)
print("Hello World!")
9 Hello World!
# -*- coding: utf-8 -*-
print(4 + 5)
print(12 - 32)
print((4 + 5) * 6)
print(4 + 5 * 6)
print(9 / 5) # 파이썬2.x 버전에서는 정수/정수 연산 결과는 정수
print(9.0 / 5.0)
print(9 / 5.0)
9 -20 54 34 1.8 1.8 1.8
print('Hello')
print("Hi there!")
Hello Hi there!
a = 'My name is '
b = 'Amenda'
print(a + b)
My name is Amenda
import sys
print(sys.version)
print()
print(sys.version_info)
3.6.1 |Anaconda custom (x86_64)| (default, May 11 2017, 13:04:09) [GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] sys.version_info(major=3, minor=6, micro=1, releaselevel='final', serial=0)
# file: cal.py
import calendar
calendar.prmonth(2014, 11)
# execfile('/Users/yhhan/Documents/workspace/python/01/cal.py')
exec(open("./files/cal.py").read())
November 2014 Mo Tu We Th Fr Sa Su 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
참고 문헌: 파이썬(열혈강의)(개정판 VER.2), 이강성, FreeLec, 2005년 8월 29일