공부/Python
1.[Python] 기본 문법
유저라인
2019. 11. 27. 12:27
728x90
반응형
num = 5
_dir = {1: 'a', 2: 'b', 3: 'c'}
a = 0
# if의 활용
if num == 5:
print("hello1")
if not 0:
print("hello2")
if not 1:
print("hello3")
else:
print("hello4")
if _dir is not None:
print(_dir)
# for 의 활용
for i in range(10):
print("i = %d" % i)
# while 의 활용
while True:
a += 1
if a == 10:
break
else:
print("a = %d" % a)
print("end")
결과 화면
hello1
hello2
hello4
{1: 'a', 2: 'b', 3: 'c'}
i = 0
i = 1
i = 2
i = 3
i = 4
i = 5
i = 6
i = 7
i = 8
i = 9
a = 1
a = 2
a = 3
a = 4
a = 5
a = 6
a = 7
a = 8
a = 9
end
import test as t
이렇게 모듈 이름을 t라는 이름으로 변경해서 쓸수 있다.
728x90
반응형