ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • [Python] for,while 반복문
    2.IT의 나비효과/② Software 2016. 7. 3. 22:24
    반응형




    >>> list1 = [1,2,3]

    >>> for i in list1 :

    print(i)


    1

    2

    3


    >>> 


    >>> for i in range(1,3):

    print(i) # range 함수는 범위보다 1개 적은 데이터를 불러온다


    1

    2

    >>> 





    >>> for i in range(1,100):

    print(i)


    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

    77

    78

    79

    80

    81

    82

    83

    84

    85

    86

    87

    88

    89

    90

    91

    92

    93

    94

    95

    96

    97

    98

    99

    >>> 







    >>> messege = '''

    "%s님, 당일 전투 참가 완료.

    당일날 전투에서 뵙겠습니다'''

    >>> name = ['유비','관우','장비']

    >>> for i in name :

    print(messege %i)



    "유비님, 당일 전투 참가 완료.

    당일날 전투에서 뵙겠습니다


    "관우님, 당일 전투 참가 완료.

    당일날 전투에서 뵙겠습니다


    "장비님, 당일 전투 참가 완료.

    당일날 전투에서 뵙겠습니다

    >>> 




    Python 3.5.1 (v3.5.1:37a07cee5969, Dec  6 2015, 01:38:48) [MSC v.1900 32 bit (Intel)] on win32

    Type "copyright", "credits" or "license()" for more information.

    >>> 

    >>> 

    >>> dan = int(input('출력단수'))

    출력단수 3

    >>> for x in range(dan, dan+10

       for y in range(1,10)

           print(x,"X",y,"=",x*y)

           

    SyntaxError: invalid syntax

    >>> print

    <built-in function print>

    >>> 

    >>> 

    >>> dan = int(input('출력단수'))

    출력단수3

    >>> or x in range(dan, dan+10

       for y in range(1,10)

           print(x,"X",y,"=",x*y)

          

    SyntaxError: invalid syntax

    >>> 

    >>> 

    >>> 

    >>> dan = int(input('출력단수'))

    출력단수3

    >>> for x in range(dan, dan+10

       for y in range(1,10)

           print(x,"X",y,"=",x*y)

           

    SyntaxError: invalid syntax

    >>> 

    >>> 

    >>> 

    >>> dan = int(input("출력"))

    출력 3

    >>> for x in range(dan,dan+1):

    for y in range(1,10):

    print(x,'X',y,'=',x*y)

    print


    3 X 1 = 3

    <built-in function print>

    3 X 2 = 6

    <built-in function print>

    3 X 3 = 9

    <built-in function print>

    3 X 4 = 12

    <built-in function print>

    3 X 5 = 15

    <built-in function print>

    3 X 6 = 18

    <built-in function print>

    3 X 7 = 21

    <built-in function print>

    3 X 8 = 24

    <built-in function print>

    3 X 9 = 27

    <built-in function print>

    >>> 

    >>> dan = int(input("출력"))

    출력3

    >>> for x in range(dan,dan+1):

    for y in range(1,10):

    print(x,'X',y,'=',x*y)

    print


    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

    <built-in function print>

    >>> 

    >>> 

    >>> 

    >>> 

    >>> 

    >>> 

    >>> dan = int(input('출력 단수 입력 !:'))

    출력 단수 입력 !:3

    >>> while x == dan :

      y = 1

      while y < 10 :

         print(x,'x',y,'=',x*y)

         y+= 1

      x+= 1


    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

    >>> 



    반응형

    댓글

Designed by Tistory.