Skip to content
Snippets Groups Projects
Commit cd030b2e authored by rejenver's avatar rejenver
Browse files

Upload New File

parent 5493837b
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.
>>> 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
>>> c
3
>>> dic = {'애플': 'www.apple.com',
'파이썬': 'www.python.org',
'마이크로소프트': 'www.microsoft.com'}
>>> for k, v in dic.items():
print("{0} : {1}".format(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:
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
마이크로소프트 www.microsoft.com
>>> def my_abs(x):
if (x < 0):
return -x
return x
SyntaxError: inconsistent use of tabs and spaces in indentation
>>> def my_abs(x):
if (x < 0):
return -x
return x
SyntaxError: unindent does not match any outer indentation level
>>> def minus(x):
x = -x
>>> a = 10
>>> minus(a)
>>> a
10
>>> def my_abs(x):
if (x < 0):
return -x
else:
return x
SyntaxError: inconsistent use of tabs and spaces in indentation
>>> minusList0(l)
Traceback (most recent call last):
File "<pyshell#37>", line 1, in <module>
minusList0(l)
NameError: name 'minusList0' is not defined
>>> def minusList(l)
SyntaxError: invalid syntax
>>> def minuslist(l):
l[0] = 20
>>> minuslist(a)
Traceback (most recent call last):
File "<pyshell#42>", line 1, in <module>
minuslist(a)
File "<pyshell#41>", line 2, in minuslist
l[0] = 20
TypeError: 'int' object does not support item assignment
>>> a = [10, 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("NDH")
name = NDH
position = staff
nationality = Korea
>>> print_personnel("NDH", nationality='USA')
name = NDH
position = staff
nationality = USA
>>> 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
<function print_personnel at 0x05E48BB8>
>>> print_personnel()
name = 홍길동
position = staff
nationality = Korea
>>> def fl(*a):
for x in a:
print(x)
>>> fl(123,456)
123
456
>>> fl("NDH", 2024)
NDH
2024
>>> fl( (1,2,3), 456, "NDH", {'a':100} )
(1, 2, 3)
456
NDH
{'a': 100}
>>> def fl(*a):
for x in a:
print(type(x), x)
>>> fl( (1,2,3), 456, "NDH", {'a':100} )
<class 'tuple'> (1, 2, 3)
<class 'int'> 456
<class 'str'> NDH
<class 'dict'> {'a': 100}
>>> a = 10
>>> a = 10.0
>>> a = "aaaaaaaa"
>>> def scope_test():
a = 100
print(a)
>>> a = 100
>>> a = 200
>>> scope_test()
100
>>> a
200
>>> bbbbb = 300
>>> bbbbbb = 200
>>> def scope_test():
a = 100
print(a * bbbbbb)
>>> scope_test
<function scope_test at 0x05E48C00>
>>> scope_test()
20000
>>> a = 100
>>> a = 10.0
>>> a = "aaa"
>>> bbbbbb = 100
>>> bbbbbb = 10.0
>>> scope_test()
1000.0
>>> def some_func(count):
if count > 0:
print(count)
some_func(count-1)
SyntaxError: inconsistent use of tabs and spaces in indentation
>>> def some_func(count):
if count > 0:
print(count)
some_func(count-1)
SyntaxError: inconsistent use of tabs and spaces in indentation
>>> def some_func(count):
if count > 0:
print(count)
some_func(count-1)
>>> some_func(10)
10
9
8
7
6
5
4
3
2
1
>>>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment