TIL 04. Python - Variables(변수)

박소윤·2020년 11월 17일
0

Python

목록 보기
2/6
post-thumbnail

Variables for Strings

name   = "송은우"
gender = "남자"

variable - name , gender
"송은우" - name , "남자" - gender의 변수값(value)

name 및 gender의 변수값은 바뀔 수 있어, Python 또한 변수값은 바뀔 수 있다.
 ## print vs variables 
 
 name = "송은우"
 print(name) ## "송은우" 출력
 
 (실제 문장에서의 특정단어를 뜻하여 문맥이 존재하나,
 name은 이름을 뜻하는 단어여서 자동차 = 내이름 이라고 뜻할수 없지만,
 Python에서는 그러한 문맥이 존재하지않아 name = "car"의 값을 저장할 수 있다.)

String

📌 "String" - 문자열(text) 값
📌 "" X - variables or function

variables name

  - name
  - _name      - 변수명앞에 숫자 불가
  - my_name  - 언더바
  - myName     - 카멜표기법(*camelCase)

* 단어와단어 사이를 공백없이 대문자로 표기

Variables For Numbers

var = 숫자 or "string"
숫자의 경우 Integer(정수) , Float(소숫점) , negative number(음수)

"string" + 숫자 print의 경우 에러발생
age = 23
next_year = age + 1
print(next_year) ## 24 출력 
profile
흐르듯 그리는 Front-end

0개의 댓글