-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathpy_tutorial.py
More file actions
76 lines (61 loc) · 925 Bytes
/
py_tutorial.py
File metadata and controls
76 lines (61 loc) · 925 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# 1.3.1 산술연산
1+2
5*4
5**4
15/4
15//4
print(1+2)
# 1.3.2 자료형
print(type(10))
print(type(2.718))
print(type("10"))
# 1.3.3 변수
x = 10
print(x)
x = 100
print(x)
y = 3.14
print(x*y)
print(type(x*y))
# 1.3.4 리스트
a = [1,2,3,4,5]
print(a)
print(len(a))
print(a[0],a[4],a[-1])
a[4] = 99
print(a)
print(a[0:3])
print(a[1:])
print(a[:3])
print(a[:-1])
# 1.3.5 딕셔너리
me = {'height':180}
print(me['height'])
me['weight'] = 74
print(me)
# 1.3.6 bool
hungry = True
sleepy = False
print(type(hungry))
print(hungry)
print(not hungry)
# 1.3.7 if문
hungry = not hungry
if hungry:
print("i'm hungry")
else :
print("i'm not hungry")
print("i'm sleepy")
# 1.3.8 for문
for i in [1,20,3]:
print(i)
for i in range(10):
print(i)
# 1.3.9 함수
def hello():
print("hello world")
hello()
def hello(object):
print("Hello " + object +"!")
hello("cat")
# hello() ## 에러발생