시작하며
시작은 했지만 항상 지속하는 것이 어렵다. 모든 책에 나와 있는 hello world는 마치 수학의 집합같은 존재이다. 너무 쉬워서 이해되지만 다음 장부터 흥미가 급격히 떨어진다.
2. 공부에 도움을 주신 분들
교재는 누구나 쉽게 배우는 파이썬 프로그래밍이다. 제이슨 R. 브리그스 저
3. 오늘 배운 것
- 파이썬 설치 – 이 책에는 구구절절히 나와있는데 아나콘다 설치하면 끝난다.
- Print(‘hello world’)
- Idle을 통한 사칙연산
- 변수에 값저장
>>> a=100
>>> print(a)
100
>>> a=200
>>> print(a)
200
- >>> syntaxError : 문법의 오류 (참고 EOL : end of line)
- 여러 라인으로 구성된 문자열 사용 ‘’’을 쓰고 엔터를 넣어라. Escaping 의 방법으로도 사용
- 여러라인
>>> jack = ”’You can’t stop me.
Please step back!
You underestimated my power.”’
>>> print(jack)
You can’t stop me.
Please step back!
You underestimated my power.
>>>
7. Escaping-\(역슬래시 이용)
>>> jack2=’You can\’t stop me. Why don\’t you step back. You\’d better go back.’
>>> print(jack2)
You can’t stop me. Why don’t you step back? You’d better go back.
8. 따옴표 사용에 따른 에러예시
홑따옴표로 에러
>>> jack2= ‘You can’t stop me. Why don’t you step back? You’d better go back.’
SyntaxError: invalid syntax
겹따옴표로 보완
>>> jack2= “you can’t stop me. Why don’t you step back? You’d better go back”
>>> print(jack2)
you can’t stop me. Why don’t you step back? You’d better go back
‘’’ 보완
>>> jack2= ”’You can’t stop me. Why don’t you step back? You’d better go back.”’
>>> print(jack2)
You can’t stop me. Why don’t you step back? You’d better go back.
9. 문자열에 값 넣기
>>> price = 1000
>>> sentence = ‘The Price of this year is %s’
>>> print(sentence % price)
The Price of this year is 1000
'Python일기' 카테고리의 다른 글
모듈 임포트하고 실행하기 (0) | 2019.05.02 |
---|---|
if 조건문 만들기 (0) | 2019.04.12 |
루프만들기(for, while문) (0) | 2019.04.12 |
리스트 만들기 (0) | 2019.04.11 |
파이썬 자료구조와 제어문 if, for (0) | 2018.11.30 |