Skip to content
Snippets Groups Projects
Commit ca172f27 authored by Minseong Kwon's avatar Minseong Kwon
Browse files

Upload New File

parent 5ae776fc
No related branches found
No related tags found
No related merge requests found
Python 3.7.1 (v3.7.1:260ec2c36a, Oct 20 2018, 14:05:16) [MSC v.1915 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> #list
>>>
>>>
>>>
>>> a=['김개똥','박짱구','이멍충']
>>> a[0]
'김개똥'
>>> a[1]
'박짱구'
>>> a2[]
SyntaxError: invalid syntax
>>> a[2]
'이멍충'
>>> a=["aaa","bbb","ccc"]
>>> a
['aaa', 'bbb', 'ccc']
>>> a[1,2]
Traceback (most recent call last):
File "<pyshell#11>", line 1, in <module>
a[1,2]
TypeError: list indices must be integers or slices, not tuple
>>> a[2]
'ccc'
>>> a[1]
'bbb'
>>> b[123,456,"789"]
Traceback (most recent call last):
File "<pyshell#14>", line 1, in <module>
b[123,456,"789"]
NameError: name 'b' is not defined
>>> b=[123,456,"79"]
>>> b
[123, 456, '79']
>>> # 슬라이싱
>>>
>>> a=[1,2,3,4,5]
>>> a[1:3}
SyntaxError: invalid syntax
>>> a[1:3]
[2, 3]
>>> len(a)
5
>>> a.pop()
5
>>> a
[1, 2, 3, 4]
>>> a.index(2)
1
>>> a.reverse()
>>> a
[4, 3, 2, 1]
>>> a="apple"
>>> a="bannana"
>>> t=(1,2,3)
>>> t=(2,4,5)
>>> s=kim
Traceback (most recent call last):
File "<pyshell#32>", line 1, in <module>
s=kim
NameError: name 'kim' is not defined
>>> s="kim"
>>> a="kim"
>>> a
'kim'
>>> s
'kim'
>>> type(t)
<class 'tuple'>
>>> a=(1,3)
>>> a
(1, 3)
>>> a=(1)
>>> a
1
>>> a=(1,)
>>> a
(1,)
>>> a=1+3&0x01
>>> a
0
>>> a=-1
>>> bin(a)
'-0b1'
>>> a=-4
>>> bin(a)
'-0b100'
>>> b=0b00110011
>>> a&b
48
>>> bin(a&b)
'0b110000'
>>> a=5
>>> ~a
-6
>>> (a*-1)==(~a+1)
True
>>> a=1,2,3
>>> a*13
(1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3)
>>> 13*a
(1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3)
>>> b="hi"
>>> b*13
'hihihihihihihihihihihihihi'
>>> 13*b
'hihihihihihihihihihihihihi'
>>> len(a)
3
>>> one,two,three=a
>>> one
1
>>> tow
Traceback (most recent call last):
File "<pyshell#65>", line 1, in <module>
tow
NameError: name 'tow' is not defined
>>> two
2
>>>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment