Notice
Recent Posts
Recent Comments
Link
«   2025/05   »
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
Tags more
Archives
Today
Total
관리 메뉴

기록

구구단 짜기 본문

PYTHON

구구단 짜기

9400 2022. 12. 23. 17:38
일반 구구단
for i in range(1,9+1):
    for j in range(1,9+1):
        print("{} * {} ={}".format(i,j,i*j))

 

짝수 구구단
for i in range(2,9+1):
    if i % 2 == 1:
          continue
    for j in range(1,9+1):
        print("{} * {} ={}".format(i,j,i*j))

 

 

메서드 구구단! 
def showdan(dan):
    print("{}*{}={}".format(dan,1,dan*1))
    print("{}*{}={}".format(dan,2,dan*2))
    print("{}*{}={}".format(dan,3,dan*3))
    print("{}*{}={}".format(dan,4,dan*4))
    print("{}*{}={}".format(dan,5,dan*5))
    print("{}*{}={}".format(dan,6,dan*6))
    print("{}*{}={}".format(dan,7,dan*7))
    print("{}*{}={}".format(dan,8,dan*8))
    print("{}*{}={}".format(dan,9,dan*9))
    
    
showdan(2)
showdan(5)
showdan(9)

'PYTHON' 카테고리의 다른 글

PYQT 클릭시마다 +1 출력하게 만들기  (0) 2023.01.02
PYQT란? PYQT를 이용하여 파이썬 프로그래밍하기  (0) 2023.01.02
파이썬 if 문, for문  (0) 2022.12.30
PYTHON Class 상속  (0) 2022.12.26
파이썬 메서드  (0) 2022.12.23
Comments