1
2
3
4
5
6
7
8
9
10
4+3
a=1
b=2
c=a+b
print("hello")
print(c)
a=int(input())
b=int(input())
result=a+b
print(a,"+",b,"=",result)




1
2
3
4
print(100+100)
print("%d",(100+100))
print("%d"%(100+100))
print("%d %d"%(100,100))

서식->%d(10진수),%x(16진수),%f(실수),%(문자),%s(문자열)



1
2
3
4
def fun_ex(num):
    n=1
    while n <=10:
        print(n,"x",num,"=",n*num)

fun_ex(숫자입력)

1 x 20 = 20

2 x 20 = 40

3 x 20 = 60

4 x 20 = 80

5 x 20 = 100

6 x 20 = 120

7 x 20 = 140

8 x 20 = 160

9 x 20 = 180

10 x 20 = 200



1
2
3
4
5
6
7
8
9
10
import time
n=1
while n < 9:
    m=1
    print(n+1,"단")
    n=n+1
    while m <= 9:
        print(n,"x",m,"=",n*m)
        m=m+1
    time.sleep(3)

8월23일자 구구단



1
2
3
4
5
6
i,k = 0,0
for i in range(2,10):
    print("--- %d 단 ---"%i)
    for k in range(1,10):
        guguLine = str("%2d X %2d = %2d"%(i,k,i*k))
        print(guguLine)

8월30일자 구구단



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
from tkinter import*
 
##변수##
window = None
canvas = None
 
x1, y1, x2, y2 = None, None, None, None
 
## 함수 ##
def mouseClick(event):
    global x1, y1, x2, y2
    x1 = event.x
    y1 = event.y
     
def mouseDrop(event):
    global x1, y1, x2, y2
    x2 = event.x
    y2 = event.y
    canvas.create_line(x1,y1,x2,y2,width=5,fill="red")
 
## 메인코드 ##
window = Tk()
window.title("그림그리기")
canvas = Canvas(window, height=300, width=300)
canvas.bind("<button-1>",mouseClick)
canvas.bind("<buttonrelease-1>",mouseDrop)
canvas.pack()
window.mainloop()
</buttonrelease-1></button-1>

0823 그림판

'먼지 낀 책장사이 > Python' 카테고리의 다른 글

쓰레드  (0) 2016.10.11
상속, 오버라이딩, 툴킷  (0) 2016.09.27
Raw파일 읽기, 클래스, 생성자  (0) 2016.09.20
가변 매개변수, 모듈  (0) 2016.09.06
연산자, while 반복, for문, 리스트/사전/튜플  (0) 2016.08.30