Skip to content
Snippets Groups Projects
Commit abc6a1e9 authored by KimMinSeob's avatar KimMinSeob
Browse files

Upload New File

parent 4e799c4d
No related branches found
No related tags found
No related merge requests found
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> 5 in range(10)
True
>>> range(10)
range(0, 10)
>>> 5 in range(10)
True
>>> 10 in range(10)
False
>>> a,b,c=(1,2,3)
>>> a
1
>>> b
2
>>> c
3
>>> >>> dic = {'애플': 'www.apple.com',
'파이썬': 'www.python.org',
'마이크로소프트': 'www.microsoft.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'}
SyntaxError: unexpected indent
>>> 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 die:
print(i,dic[i])
Traceback (most recent call last):
File "<pyshell#22>", line 1, in <module>
for i in die:
NameError: name 'die' is not defined
>>> for i in dic:
print(i,dic[i])
애플 www.apple.com
파이썬 www.python.org
마이크로소프트 www.microsoft.com
>>> 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
>>> for i in dic:
if(i == '마이크로소프트'):
print(i,dic[i])
break
>>> #break 의 위치에 대한 것 . if 안에 있냐 아니냐
>>> for i in range(10):
if i % 2 ==1:
continue
print(i)
0
2
4
6
8
>>> #continue 하면 다시 루프의 처음으로 돌아간다.
>>> def hello():
print("Hello , World")
>>> hello()
Hello , World
>>> def abs(arg):
if(arg<0):
result = arg * -1
else:
result = arg
>>> value = abs(10)
>>> value
>>>
>>>
>>>
>>> def abs(arg):
if(arg<0):
result = arg *-1
else:
result = arg
return result
>>> value = abs(10)
>>> value
10
>>> value = abs(-10)
>>> value
10
>>> def minus(x):
x=-x
>>> a=10
>>> a
10
>>> a = minus(a)
>>> a
>>> a
>>> a
a
>>>
>>> a
>>> a
a
>>>
a
>>>
a
>>>
a
>>>
a
>>>
a
>>>
>>> a
a
>>>
>>> a
>>> a
>>> a
>>> a = 10
>>> a
10
>>> minus(a)
>>> a
10
>>> a = [10,20]
>>> minus(a)
Traceback (most recent call last):
File "<pyshell#99>", line 1, in <module>
minus(a)
File "<pyshell#73>", line 2, in minus
x=-x
TypeError: bad operand type for unary -: 'list'
>>> minus([a])
Traceback (most recent call last):
File "<pyshell#100>", line 1, in <module>
minus([a])
File "<pyshell#73>", line 2, in minus
x=-x
TypeError: bad operand type for unary -: 'list'
>>> minus(a[0])
>>> a
[10, 20]
>>> def minuslist(l):
l[0]=20
>>> minuslist(a)
>>> a
[20, 20]
>>> #리스트는 함수를 통해 값을 변경할수있다.
>>> 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('kimminseob')
name = kimminseob
position = staff
nationality = Korea
>>> print_personnel('kimminseob',nationality = 'usa')
name = kimminseob
position = staff
nationality = usa
>>> def print_personnel(name='kimminseob', position='staff', nationality='Korea'):
print('name = {0}'.format(name))
print('position = {0}'.format(position))
print('nationality = {0}'.format(nationality))
>>> print_personnel(position = 'ceo')
name = kimminseob
position = ceo
nationality = Korea
>>> print_personnel()
name = kimminseob
position = staff
nationality = Korea
>>> def fl(*a)
SyntaxError: invalid syntax
>>> def fl(*a):
for x in a:
print(type(x),x)
>>> fl(123,(3,4,5),"김민섭",{a = 12345})
SyntaxError: invalid syntax
>>> fl(123,(3,4,5),"김민섭",{a ==12345})
<class 'int'> 123
<class 'tuple'> (3, 4, 5)
<class 'str'> 김민섭
<class 'set'> {False}
>>> def print_team(**players):
for k in players.keys():
print('{0} = {1}'.format(k, players[k]))
>>> print_team(카시야스='GK', 호날두='FW', 알론소='MF', 페페='DF')
카시야스 = GK
호날두 = FW
알론소 = MF
페페 = DF
>>> a= 10
>>> a= 10.0
>>> a
10.0
>>> a = "aaaaa"
>>>
Traceback (most recent call last):
File "<pyshell#129>", line 1, in <module>
NameError: name '' is not defined
>>> a
'aaaaa'
>>>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment