본문 바로가기

Python_Matter/Solve

Python Learn the basics Quiz 18

728x90

Q>

구구단 함수를 작성하여 3단과 5단을 출력하시오.


A>

def gugu(a):
for i in range(1, 10):
print(a, 'x', i, '=', i * a)

gugu(3)
print('-' * 10)
gugu(5)


O>

3 x 1 = 3

3 x 2 = 6

3 x 3 = 9

3 x 4 = 12

3 x 5 = 15

3 x 6 = 18

3 x 7 = 21

3 x 8 = 24

3 x 9 = 27

----------

5 x 1 = 5

5 x 2 = 10

5 x 3 = 15

5 x 4 = 20

5 x 5 = 25

5 x 6 = 30

5 x 7 = 35

5 x 8 = 40

5 x 9 = 45


Process finished with exit code 0


반응형

'Python_Matter > Solve' 카테고리의 다른 글

Python Learn the basics Quiz 20  (0) 2019.03.28
Python Learn the basics Quiz 19  (0) 2019.03.27
Python Learn the basics Quiz 18  (0) 2019.03.27
Python Learn the basics Quiz 17  (0) 2019.03.27
Python Learn the basics Quiz 16  (0) 2019.03.27
Python Learn the basics Quiz 15  (0) 2019.03.27