The basic string types

 

String (in quotes):

    name = "我是xx"  name = 'xx'  name = '''xxx'''  name  """xxx"""

  String addition:

    n1 = "xx" n2 = "nb" n3 = n1 + n2 n3 = "xxnb" two strings are added 

  String multiplication:

    n1 = "alex" n2 = n1 * 10 print ten times alex 

  digital:

    a1 = 10 a2 = 20 age = 13 # number can not quotes

    a3 = a1 + a2 a3 = a1 - a2 a3 = a1 * a2 a3 = a1 / a2 a3 = a1% a2 # acquires remainder a3 = a1 // a2 rounded

Loop: while

  Endless loop

    while 1==1:
      print('ok')

Exercise: 1 while loop input 12345689

     2. All numbers 1-100 and seek

    3. Enter all odd 1-100

    4. Enter the number of all the even-numbered 1-100

    The request 1-2 + 3-4 + 5 .. . 99 and the number of all

    6. User Login (three opportunities)

 

 

 

 

 

  Out of the loop continue terminates the current cycle, a cycle break the cycle at the beginning of an end to all  

 

Guess you like

Origin www.cnblogs.com/gpsj/p/11373665.html