Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 31 |
Tags
- 얕은 복사
- node.js
- 셔뱅
- 스트림
- arraycopy
- pycharm
- Up Casting
- singletone
- Stream
- lambda
- identityHashCode
- has-a
- generic programming
- finalize
- dbeaver
- shebang
- Wrapper class
- 자바
- access modifier
- Inbound
- extends
- 깊은 복사
- parameter group
- public static final
- 파이참
- 내부클래스
- 엔드포인트
- Java
- down casting
- constructor
Archives
- Today
- Total
٩(๑•̀o•́๑)و
Variable 본문
# 변수 규칙
- 영문 문자와 숫자 사용 가능
- 대소문자 구분
- 문자부터 시작해야 함
- _로 시작 가능
- 특수문자 사용 불가
- 파이썬의 키워드 사용 불가
>>> x = 10
>>> y = 'hello'
>>> print(x)
10
>>> print(y)
hello
>>> type(x)
<class 'int'>
>>> type(y)
<class 'str'>
>>> x1, y1 = 10, 'hello'
>>> print(x1, y1)
10 hello
>>> type(x1)
<class 'int'>
>>> type(y1)
<class 'str'>
>>> x, y = 10, 20
>>> x, y = y,x
>>> print(x, y)
20 10
>>> print(x)
20
>>> del x
>>> print(x)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'x' is not defined
>>> x = None # null과 동일
>>> print(x)
None
>>> type(x)
<class 'NoneType'>
>>> x = 10
>>> x += 2 # x = x+2
>>> x
12
>>> x = input()
hello world
>>> print(x)
hello world
>>> y = input('입력 : ')
입력 : input
>>> print(y)
input
>>> a = int(input('숫자1 : '))
숫자1 : 3
>>> b = int(input('숫자2 : '))
숫자2 : 4
>>> a+b
7
>>> a,b = input('input1, input2 : ').split() #공백으로 구분
input1, input2 : 3 4
>>> print(a); print(b);
3
4
>>> a, b = input('input1, input2 : ').split(',')
input1, input2 : 3,4
>>> print(a); print(b);
3
4
>>> a, b = map(int, input('input1, input2 : ').split())
input1, input2 : 3 5
>>> a+b
8
>>> a, b = map(int, input('input1, input2 : ').split(','))
input1, input2 : 4, 6
>>> a+b
10
>>>
# 파이썬에서의 변수와 값 : 파이썬은 값 자체도 객체. 따라서 변수는 객체를 가리키는 방식을 사용함.
>>> x = 10
>>> y = 10
>>> print(x is y)
True