끼적거리다가 본격적으로 연습 시작.

최종 목표는 LDPC decoder 시뮬레이터 여러 방법으로 실행하기


https://www.codecademy.com/learn/python


1.

print "Welcome to Python!"


2. 변수, 숫자

# Write your code below!

my_variable = 10


3. 변수, 실수, 불리언

my_int = 7

my_float = 1.23

my_bool = True


4. 변수 재 어사인

my_int = 7

# Change the value of my_int to 3 on line 8!

my_int =3

print my_int


5. python 에서 공백은 code structure 에 영향을 줌, space 나 tab 으로 indentation 함으로써 코드 구성 가능

def spam():

 eggs = 12

 return eggs

        

print spam()


6. interpreter 이해

spam = True

eggs = False


7. python 에서의 comment 는 #

#this is comment for python

mysterious_variable = 42


8. multi-line comment 는 큰따옴표 세 개 사이에 넣기

"""multi line comment

comment

comment

"""


9. 산술연산 ; 덧셈

# Set count_to equal to the sum of two big numbers

a_big = 1000000

b_big = 20102301


count_to = a_big+b_big


print count_to


10. 지수승은 ** 

eggs = 10**2


print eggs


11. 모듈로 연산은 똑같음 %

spam =5%4

print spam


12. 종합

# all together

monty = True

python = 1.234

monty_python = python**2



13. meal 계산

# Assign the variable total on line 8!


meal = 44.50

tax = 0.0675

tip = 0.15


meal = meal + meal * tax


total = meal + meal*tip

print("%.2f" % total)

'Python' 카테고리의 다른 글

functions  (0) 2016.02.08
Pig Latin  (0) 2016.02.08
Conditional and control flow  (0) 2016.02.05
datetime library  (0) 2016.02.04
string  (0) 2016.02.02

+ Recent posts