Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
python.study
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
장범진
python.study
Commits
9df335c6
Commit
9df335c6
authored
6 years ago
by
장범진
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
f127fee1
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
function.py
+239
-0
239 additions, 0 deletions
function.py
with
239 additions
and
0 deletions
function.py
0 → 100644
+
239
−
0
View file @
9df335c6
Python
3.7
.
0
(
v3
.
7.0
:
1
bf9cc5093
,
Jun
27
2018
,
04
:
59
:
51
)
[
MSC
v
.
1914
64
bit
(
AMD64
)]
on
win32
Type
"
copyright
"
,
"
credits
"
or
"
license()
"
for
more
information
.
>>>
9
in
range
(
10
)
True
>>>
10
in
range
(
10
)
False
>>>
0
in
range
(
10
)
True
>>>
range
(
10
)
range
(
0
,
10
)
>>>
dic
=
{
"
애플
"
:
"
www.apple.com
"
.}
SyntaxError
:
invalid
syntax
>>>
dic
=
{
"
애플
"
:
"
www.apple.com
"
.}
SyntaxError
:
invalid
syntax
>>>
dic
=
{
"
애플
"
:
"
www.apple.com
"
.}
SyntaxError
:
invalid
syntax
>>>
dic
=
{
"
애플
"
:
"
www.apple.com
"
.
"
파이썬
"
:
"
www.python.org
"
"
마이크로 소프트
"
:
"
www.microsoft.com
"
}
SyntaxError
:
invalid
syntax
>>>
dic
=
{
"
애플
"
:
"
www.apple.com
"
,
"
파이썬
"
:
"
www.python.org
"
,
"
마이크로 소프트
"
:
"
www.microsoft.com
"
}
>>>
for
k
,
v
in
dic
.
items
():
print
(
k
,
v
)
애플
www
.
apple
.
com
파이썬
www
.
python
.
org
마이크로
소프트
www
.
microsoft
.
com
>>>
for
i
in
dic
:
print
(
i
)
애플
파이썬
마이크로
소프트
>>>
for
i
in
dic
:
print
(
i
,
dic
[
i
])
애플
www
.
apple
.
com
파이썬
www
.
python
.
org
마이크로
소프트
www
.
microsoft
.
com
>>>
for
i
in
dic
:
print
(
i
,
dic
{
i
})
SyntaxError
:
invalid
syntax
>>>
for
i
in
dic
:
print
(
i
,
dic
(
i
))
Traceback
(
most
recent
call
last
):
File
"
<pyshell#20>
"
,
line
2
,
in
<
module
>
print
(
i
,
dic
(
i
))
TypeError
:
'
dict
'
object
is
not
callable
>>>
for
i
in
dic
:
if
(
i
==
"
애플
"
)
SyntaxError
:
invalid
syntax
>>>
for
i
in
dic
:
if
(
i
==
"
애플
"
):
print
(
i
,
dic
[
i
])
애플
www
.
apple
.
com
>>>
for
i
in
dic
:
if
(
i
==
"
애플
"
):
print
(
i
,
dic
[
i
])
break
애플
www
.
apple
.
com
>>>
def
abs
(
x
)
SyntaxError
:
invalid
syntax
>>>
def
abs
(
x
):
if
x
<
0
:
return
-
x
return
x
>>>
abs
(
100
)
100
>>>
abs
(
-
100
)
100
>>>
type
(
abs
)
<
class
'
function
'
>
>>>
def
minus
(
x
):
x
=
-
x
>>>
minus
(
100
)
>>>
minus
(
-
100
)
>>>
def
minus
(
x
):
x
=
-
x
return
x
>>>
minus
(
-
100
)
100
>>>
minus
(
100
)
-
100
>>>
def
print_personnel
(
name
,
position
=
"
staff
"
,
nationality
=
"
Korea
"
):
print
(
"
name = {0}
"
,
format
(
name
))
print
(
"
position = {0}
"
,
format
(
position
))
print
(
"
nationality = {0}
"
,
format
(
nationality
))
>>>
print
(
"
장범진
"
)
장범진
>>>
print_personnel
(
"
장범진
"
)
name
=
{
0
}
장범진
position
=
{
0
}
staff
nationality
=
{
0
}
Korea
>>>
def
print_personnel
(
name
,
position
=
"
staff
"
,
nationality
=
"
Korea
"
):
print
(
'
name = {0}
'
,
format
(
name
))
print
(
'
position = {0}
'
,
format
(
position
))
print
(
'
nationality = {0}
'
,
format
(
nationality
))
SyntaxError
:
unexpected
indent
>>>
def
print_personnel
(
name
,
position
=
"
staff
"
,
nationality
=
"
Korea
"
):
print
(
'
name = {0}
'
,
format
(
name
))
print
(
'
position = {0}
'
,
format
(
position
))
print
(
'
nationality = {0}
'
,
format
(
nationality
))
>>>
print_personnel
(
"
장범진
"
)
name
=
{
0
}
장범진
position
=
{
0
}
staff
nationality
=
{
0
}
Korea
>>>
def
print_personnel
(
name
,
position
=
"
staff
"
,
nationality
=
"
Korea
"
):
print
(
'
name = {0}
'
.
format
(
name
))
print
(
'
position = {0}
'
.
format
(
position
))
print
(
'
nationality = {0}
'
.
format
(
nationality
))
SyntaxError
:
unexpected
indent
>>>
def
print_personnel
(
name
,
position
=
"
staff
"
,
nationality
=
"
Korea
"
):
print
(
'
name = {0}
'
.
format
(
name
))
print
(
'
position = {0}
'
.
format
(
position
))
print
(
'
nationality = {0}
'
.
format
(
nationality
))
>>>
print_personnel
(
"
장범진
"
)
name
=
장범진
position
=
staff
nationality
=
Korea
>>>
def
fl
(
*
a
):
for
x
in
a
:
print
(
x
)
>>>
fl
(
123
,
456
)
123
456
>>>
fl
(
"
이환용
"
,
2024
)
이환용
2024
>>>
type
(
*
a
)
Traceback
(
most
recent
call
last
):
File
"
<pyshell#70>
"
,
line
1
,
in
<
module
>
type
(
*
a
)
NameError
:
name
'
a
'
is
not
defined
>>>
type
(
*
)
SyntaxError
:
invalid
syntax
>>>
int
*
a
Traceback
(
most
recent
call
last
):
File
"
<pyshell#72>
"
,
line
1
,
in
<
module
>
int
*
a
NameError
:
name
'
a
'
is
not
defined
>>>
type
(
fl
)
<
class
'
function
'
>
>>>
def
merge_string
(
*
text_list
):
result
=
''
for
s
in
text_list
:
result
=
result
+
s
returtn
result
SyntaxError
:
invalid
syntax
>>>
def
merge_string
(
*
text_list
):
result
=
''
for
s
in
text_list
:
result
=
result
+
s
return
result
>>>
merge_string
(
'
아버지
'
,
'
가
'
,
'
방에
'
,
'
들어가신다
'
)
'
아버지가방에들어가신다
'
>>>
def
fl
(
*
a
):
for
x
in
a
:
print
(
type
(
x
),
x
)
>>>
fl
((
1
,
2
,
3
),
456
,
"
장범진
"
,{
"
a
"
:
100
})
<
class
'
tuple
'
> (1, 2, 3)
<class
'
int
'
> 456
<class
'
str
'
> 장범진
<class
'
dict
'
> {
'
a
'
: 100}
>>>
def
scope_test
():
a
=
100
print
(
a
)
>>>
a
=
100
>>>
a
=
200
>>>
scope_test
(
a
)
Traceback
(
most
recent
call
last
):
File
"
<pyshell#91>
"
,
line
1
,
in
<
module
>
scope_test
(
a
)
TypeError
:
scope_test
()
takes
0
positional
arguments
but
1
was
given
>>>
scope_test
()
100
>>>
a
200
>>>
def
scope_test
():
a
=
100
print
(
a
*
b
)
>>>
scope_test
<
function
scope_test
at
0x000001AF760BF598
>
>>>
scope_test
()
Traceback
(
most
recent
call
last
):
File
"
<pyshell#97>
"
,
line
1
,
in
<
module
>
scope_test
()
File
"
<pyshell#95>
"
,
line
3
,
in
scope_test
print
(
a
*
b
)
NameError
:
name
'
b
'
is
not
defined
>>>
def
scope_test
():
global
a
a
=
1
print
(
'
a:{0}
'
.
format
(
a
))
>>>
>>>
a
=
0
>>>
scope_test
()
a
:
1
>>>
print
(
"
a
"
)
a
>>>
print
(
"
a:{0}
"
.
format
(
a
))
a
:
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