1.

brian = "Hello life!"


2. 문자열 변수 할당 및 출력

# Assign your variables below, each on its own line!


caesar = "Graham"

praline = "John"

viking = "Teresa"


# Put your variables above this line


print caesar

print praline

print viking


3. 특문은 역슬래시

'This isn\'t flying, this is falling with style!'


4. index starts from 0

string = "MONTY"

fifth_letter = string[4]


print fifth_letter


5. 문자열 길이 함수

parrot = "Norwegian Blue"

print len(parrot)


6. 문자열 함수 사용법 - 뭔가 문자열 객체에다가 점 찍어서 관련 함수를 사용하는 듯

parrot = "Norwegian Blue"

print parrot.lower()

print parrot.upper()


7.  문자열로 변환하는 함수

pi = 3.14

print str(pi)


8. dot notation 사용 주의

ministry = "The Ministry of Silly Walks"


print len(ministry)

print ministry.upper()


9. print string

print "Monty Python"


10. 문자열 변수 출력하기

the_machine_goes = "Ping!"

print the_machine_goes


11. string concatenation

print "Spam " + "and " + "eggs"

print "The value of pi is around " + str(3.14)


12. 문자열 포맷 지정자: %s 로 큰 따옴표 내에서 문자열 대치할 수 있음 

    대치되는 문자열 변수들은 큰 따옴표 뒤에 %(변수 나열)  식으로 해서 넣음

    "문자열 %s" %(string)

name = raw_input("What is your name?")  #문자열 입력 받아오는 함수 with comment

quest = raw_input("What is your quest?")

color = raw_input("What is your favorite color?")


print "Ah, so your name is %s, your quest is %s, " "and your favorite color is %s." % (name, quest, color)


13.

my_string = "Keol Cho"

print len(my_string)

print my_string.upper()




'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
python 걸음마 시작  (0) 2016.02.02

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

최종 목표는 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

#include <iostream>


int main(void){

std::cout << "Hello world!" << std::endl;

std::cout << 1 << 'a' << "String" << std::endl;

return 0;

}


strcat 같은 함수가 필요없구나.

예제코드 다 코딩하기 보다는 연습문제 풀면서 공부하자.


연습문제 


1-1-1


#include <iostream>


int main(void){

int in[10];

int sum = 0;

for (int i = 0; i < 10; i++)

{

std::cout << i + 1 << "번째 수 입력:";

std::cin >> in[i];

sum += in[i];

}

std::cout << "합계: " << sum << std::endl;


return 0;

}


1-1-2 

#include <iostream>


int main(void){

char name[50];

char phone[15];


std::cout << "Name: ";

std::cin >> name;


std::cout << "Phone#: ";

std::cin >> phone;


std::cout << "Name : " << name << std::endl << "Phone Number: " << phone << std::endl;


return 0;

}

String 따로 배우면 또 달라지겠지


1-1-3

#include <iostream>


int main(void){

int input;


std::cout << "Number: ";

std::cin >> input;

for (int i = 1; i < 10; i ++)

std::cout << input << " X " << i << " = " << input*i << std::endl;


return 0;

}







'C and C++' 카테고리의 다른 글

OpenMP in Macbook  (0) 2016.03.10
OpenMP  (0) 2016.03.09
C언어 최적화 기법  (0) 2016.02.05
Fixed point with C++  (0) 2015.12.08
C++ , 객체지향  (0) 2015.12.08

LDPC Decoder를 C++로 뜯어고치기 프로젝트를 들어가기로 했다.


괜히 fixed point가 가능한 라이브러리들을 찾아보았는데 링크를 그냥 날려버리기 뭣해서 블로그에 정리해둔다.


http://stackoverflow.com/questions/2945747/c-fixed-point-library

이 글에 다양한 링크들이 있는데 몇가지 추리자면,


http://www.codeproject.com/Articles/37636/Fixed-Point-Class


https://alikhuram.wordpress.com/2013/05/20/implementing-fixed-point-numbers-in-c/

'C and C++' 카테고리의 다른 글

OpenMP in Macbook  (0) 2016.03.10
OpenMP  (0) 2016.03.09
C언어 최적화 기법  (0) 2016.02.05
걸음마  (0) 2015.12.08
C++ , 객체지향  (0) 2015.12.08

C++ 공부자료는 윤성우 라는 분의 열혈강의 프로그래밍,

그리고 각종 블로그들이다.

우선 메인으로 보는 블로그는 바로 여기.

http://wkdghcjf1234.blog.me/220387088319


C++은 학부시절 들을 기회가 있었는데, 수강신청을 실패했고, 증원되지 않아서 결국 듣지 못했다.

전공 시간에 억지로 과제라도 하면서 익혔으면 지금 공부하는데 훨씬 더 마주하기가 쉬웠을텐데.. 하는 아쉬움이 남지만, 그래도 어쩌겠는가.

'가장 빠른 때가 지금이다'라는 말도 있지 않는가. 


무튼 지나간 날은 모두 뒤로 하고, 다가올 객체 지향을 향해 할로 해보자.


객체지향이라는 말은 소프트웨어 공학 시간에 UML을 배우면서 처음으로 제대로 듣게 되었는데, 그때도 역시 제대로 이해되지 않았다.

왜냐하면.. 객체지향이라고 하더라도 결국 프로그램이 순서대로 실행되는거 아닌가 하는 게 가장 걸렸기 때문이다. 

뭐가 다른거지..? 왜 따로 부르지..?


AVR 강의를 하러 갔을 때 수강생 중 한명이 면접을 보러 갔더니 객체지향과 절차지향에 대해 설명하라고 했단다.

처음 객체지향이라는 말을 들은지 한참이나 지났음에도 아직 이해를 못하고 있었던 터라, 연구실로 돌아와 동료 형에게 물어보았다.


연구실 형도 처음에는 절차지향과 상반되는 식으로 객체지향을 설명하자 석연치 않아 하셨다. 

그래서 포풍 검색 끝에 정말 잘 정리되어 있는 포스팅 하나를 발견했다.

http://blog.naver.com/atalanta16/220249264429

요약하자면, 객체지향과 절차지향은 프로그래밍 언어의 특성을 나타낸 것이라기 보다는,

개발을 하는 방법의 특성에 따라 분류하는 것이라는 것.

객체 지향 프로그래밍을 한다고 하더라도 절차대로 하지 않는다는 뜻이 절대 아니라는 것.

명심하며 공부를 시작해보자.


'C and C++' 카테고리의 다른 글

OpenMP in Macbook  (0) 2016.03.10
OpenMP  (0) 2016.03.09
C언어 최적화 기법  (0) 2016.02.05
걸음마  (0) 2015.12.08
Fixed point with C++  (0) 2015.12.08

+ Recent posts