Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
python_study123
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Joo byeong jin
python_study123
Commits
38464869
Commit
38464869
authored
6 years ago
by
Joo byeong jin
Browse files
Options
Downloads
Patches
Plain Diff
기말준비
parent
2ac90bd9
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
시험전 마지막 정리..py
+307
-0
307 additions, 0 deletions
시험전 마지막 정리..py
with
307 additions
and
0 deletions
시험전 마지막 정리..py
0 → 100644
+
307
−
0
View file @
38464869
Python
3.7
.
1
(
v3
.
7.1
:
260
ec2c36a
,
Oct
20
2018
,
14
:
05
:
16
)
[
MSC
v
.
1915
32
bit
(
Intel
)]
on
win32
Type
"
help
"
,
"
copyright
"
,
"
credits
"
or
"
license()
"
for
more
information
.
>>>
b
=
"""
hello.
world.
"""
>>>
b
'
hello.
\n
world.
\n
'
>>>
type
(
b
)
<
class
'
str
'
>
>>>
a
=
"
hello
"
>>>
a
'
hello
'
>>>
a
=
'
hello
'
>>>
a
'
hello
'
>>>
a
+
b
'
hellohello.
\n
world.
\n
'
>>>
a
*
4
'
hellohellohellohello
'
>>>
# 문자열은 '+,*' 가능.
>>>
>>>
s
=
'
good morning
'
>>>
s
[
0
]
'
g
'
>>>
s
[
0
:
4
]
'
good
'
>>>
'
sdasd
'
in
s
False
>>>
len
(
s
)
12
>>>
c
=
'
\n\n\n
'
>>>
c
'
\n\n\n
'
>>>
len
(
c
)
3
>>>
c
=
'
\\
n
\\
n
\\
n
'
>>>
c
'
\\
n
\\
n
\\
n
'
>>>
len
(
c
)
6
>>>
b
=
'
1234
'
>>>
b
.
isnumeric
()
True
>>>
b
=-
2
>>>
bin
(
b
)
'
-0b10
'
>>>
b
-
2
>>>
9
&
10
8
>>>
9
^
10
3
>>>
## &는 논리 곱으로 둘다 1인경우만 1로 표현된다.
44
+>>>
## 9 = 1001
45
+>>>
## 10= 1010
46
+>>>
## 8 = 1000
SyntaxError: invalid character in identifier
>>>
>>>
>>>
## ^는 배타적 논리합 으로 둘다 다른 경우만 1이다.
51
+>>>
## 9 = 1001
52
+>>>
## 10= 1010
53
+>>>
## 3 = 0011
SyntaxError: invalid syntax
>>>
>>>
a
=
255
>>>
~
a
-
256
>>>
a
255
>>>
## 비트연산자 ~ 는 이진수표현에서 0을 1로, 1을 0으로 뒤집고 -1을 한값이다.
>>>
>>>
a
=
2340
>>>
~
a
-
2341
>>>
bin
(
a
)
'
0b100100100100
'
>>>
bin
(
~
a
)
'
-0b100100100101
'
>>>
a
=
76
>>>
bin
(
a
)
'
0b1001100
'
>>>
9
|
10
11
>>>
a
=
15
>>>
bin
(
15
)
'
0b1111
'
>>>
bin
(
15
&
0b1011
)
'
0b1011
'
>>>
~
a
-
16
>>>
a
=
[
'
가나다
'
,
'
마바사
'
,
'
123
'
]
>>>
ㅁ
[
0
]
Traceback
(
most
recent
call
last
):
File
"
<pyshell#52>
"
,
line
1
,
in
<
module
>
ㅁ
[
0
]
NameError
:
name
'
ᄆ
'
is
not
defined
>>>
a
[
0
]
'
가나다
'
>>>
## 리스트에는 숫자와 문자열을 같이 넣을수 있다.
>>>
>>>
a
=
[
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
]
>>>
a
[
0
:
5
]
[
1
,
2
,
3
,
4
,
5
]
>>>
a
[
8
:]
[
9
,
10
]
>>>
a
=
[
'
가나다
'
,
'
마바사
'
,
'
123
'
]
>>>
len
(
a
)
3
>>>
a
[
2
]
'
123
'
>>>
a
=
[
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
]
>>>
a
[
4
]
=
11
>>>
a
[
1
,
2
,
3
,
4
,
11
,
6
,
7
,
8
,
9
,
10
]
>>>
a
=
[
1
,
2
,
3
,
12
,
123
,
234124
,
23
]
>>>
a
.
sort
()
>>>
>>>
a
[
1
,
2
,
3
,
12
,
23
,
123
,
234124
]
>>>
#오름차순 정렬
>>>
>>>
>>>
>>>
>>>
>>>
a
=
(
1
,
2
,
3
)
>>>
a
[
0
]
1
>>>
a
[
0
]
=
4
Traceback
(
most
recent
call
last
):
File
"
<pyshell#77>
"
,
line
1
,
in
<
module
>
a
[
0
]
=
4
TypeError
:
'
tuple
'
object
does
not
support
item
assignment
>>>
## 튜플 - 변경이 불가능한 자료형.( 문자열도 변경x )
>>>
>>>
a
=
1
>>>
a
1
>>>
type
(
a
)
<
class
'
int
'
>
>>>
a
=
1
,
>>>
a
(
1
,)
>>>
type
(
a
)
<
class
'
tuple
'
>
>>>
## 요소가 하나인 경우에는 , 를 반드시 추가.
>>>
>>>
a
=-
4
>>>
b
=
51
>>>
a
&
b
48
>>>
0b110000
48
>>>
a
|
b
-
1
>>>
a
-
4
>>>
>>>
>>>
>>>
## index 함수는 몇번째에 성분이있는지 찾아주는함수.
52
+>>>
a
=
1
,
2
,
3
53
+>>>
a
54
+
(
1
,
2
,
3
)
55
+>>>
a
.
index
(
2
)
56
+
1
57
+>>>
SyntaxError: invalid syntax
>>>
>>>
bin
(
-
1
)
'
-0b1
'
>>>
bin
(
-
5
)
'
-0b101
'
>>>
bin
(
51
)
'
0b110011
'
>>>
-
5
|
51
-
5
>>>
-
5
&
51
51
>>>
~
1
-
2
>>>
dic
[
'
파이썬
'
]
=
"
ㅈㅈㅈㅈ
"
Traceback
(
most
recent
call
last
):
File
"
<pyshell#104>
"
,
line
1
,
in
<
module
>
dic
[
'
파이썬
'
]
=
"
ㅈㅈㅈㅈ
"
NameError
:
name
'
dic
'
is
not
defined
>>>
dic
=
{}
>>>
dic
[
'
파이썬
'
]
=
"
ㅈㅈㅈㅈ
"
>>>
파이썬
Traceback
(
most
recent
call
last
):
File
"
<pyshell#107>
"
,
line
1
,
in
<
module
>
파이썬
NameError
:
name
'
파이썬
'
is
not
defined
>>>
dic
[
'
파이썬
'
]
'
ㅈㅈㅈㅈ
'
>>>
'
파이썬
'
in
dic
.
keys
()
True
>>>
>>>
b
=
([
1
,
2
,
3
],[
4
,
5
,
6
])
>>>
>>>
b
([
1
,
2
,
3
],
[
4
,
5
,
6
])
>>>
b
[
0
]
[
1
,
2
,
3
]
>>>
b
[
0
][
0
]
=
9
>>>
b
([
9
,
2
,
3
],
[
4
,
5
,
6
])
>>>
0xffff
65535
>>>
a
=
3
>
2
>>>
a
True
>>>
type
(
a
)
<
class
'
bool
'
>
>>>
## bool값에서는 0 을 제외한 모든 값이 참이다.
>>>
>>>
>>>
>>>
## continue 와 break 의 차이점
4
+>>>
## break는 조건이만족되면 함수중단.
5
+>>>
## continue는 조건이만족되면, 다시 조건문으로 올라간다.
SyntaxError: invalid syntax
>>>
for
i
in
range
(
10
):
if
i
%
2
==
1
:
continue
print
(
i
)
0
2
4
6
8
>>>
for
i
in
range
(
10
):
if
i
%
2
==
1
:
break
print
(
i
)
0
>>>
a
=
100
>>>
def
local_test
():
a
=
200
print
(
a
)
>>>
a
100
>>>
local_test
()
200
>>>
a
100
>>>
## 함수안에서 사용되는 변수는 값이 한번 사용되고 값이 사라진다.
>>>
>>>
>>>
def
local_test
():
global
a
a
=
200
print
(
a
)
>>>
local_test
()
200
>>>
a
200
>>>
0xf0
240
>>>
16
*
15
240
>>>
a
=
2
+
3j
>>>
a
(
2
+
3j
)
>>>
type
(
a
)
<
class
'
complex
'
>
>>>
>>>
>>>
import
math
>>>
math
.
pi
3.141592653589793
>>>
a
=
(
1
,
2
,
3
,
4
,
5
,
6
)
>>>
a
[:
3
]
(
1
,
2
,
3
)
>>>
a
[
0
]
1
>>>
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment