自学python 1.

1.变量命名规范    1.数字,字母,下划线    2.不能数字开头和纯数字    3.要有意义    4.不要太长    5.驼峰和下划线    6.不要用中文    7.不能用关键字    8.区分大小写2.name = input(">>>")    name是字符串str3.if 条件:    代码块

  if 条件1:    代码块1   else:    代码块2

   if 条件:    代码块1   elif 条件2:    代码块2   ...   else:    代码块n4.print("文能提笔安天下,")  print("武能上马定乾坤.")  print("心存谋略何人胜,")  print("古今英雄唯是君.")

  print('''x  x  x  x''')5.num = int(input("请输入数字:"))if num>66:    print("大")elif num<66:    print("小")else:    print("正确")

6.age = int(input("请输入年龄:"))if age<10:    print("小屁孩")elif 10<=age<20:      print("青春期叛逆的小屁孩")elif 20<=age<30:    print("开始定性")elif 30<=age<40:    print("老大不小")elif 40<=age<50:    print("家里有个")elif 50<=age<60:    print("老屁孩")elif 60<=age<70:    print("活着还不错")elif 70<=age<90:    print("快结束")else:    print("再见了")

#elif也可以用if

7.注释  单行 #  多行 '''       '''

8.word = input("请输入麻花腾:")if word=="马化腾":    print("你真聪明")else:    print("sb")

9.mon = int(input("请输入月份:"))if mon==1:    print("一月,饺子")elif mon==2:    print("二月,饺子")elif mon==3:    print("三月,饺子")elif mon==4:    print("四月,饺子")elif mon==5:    print("五月,饺子")elif mon==6:    print("六月,包子")elif mon==7:    print("七月,包子")elif mon==8:    print("八月,包子")elif mon==9:    print("九月,包子")elif mon==10:    print("十月,包子")elif mon==11:    print("十一月,包子")else:    print("十二月,包子")

#elif可以用if

10.mon = int(input("请输入分数:"))if mon>=90:    print("A")elif mon>=80:    print("B")elif mon>=70:    print("C")elif mon>=60:    print("D")else:    print("E")
上一篇:解决svn更新项目目录时“Error:svn: E155037: Previous operation has not finished; run 'cleanup' if it was interrupted”的报错问题


下一篇:Object-C日志记录