python,第一天

2019-10-22

1、安装python,IDE工具pycharm。。。。

    环境变量配置【右键计算机】--》【属性】--》【高级系统设置】--》【高级】--》【环境变量】--》【在第二个内容框中找到 变量名为Path 的一行,双击】 --> 【Python安装目录追加到变值值中,用 ; 分割】    如:原来的值;C:\python27,切记前面有分号
        安装方法:参见该大大的https://www.cnblogs.com/yuxuefeng/p/9235431.html

2、变量

  • 变量名只能是 字母、数字或下划线的任意组合
  • 变量名的第一个字符不能是数字
  • 以下关键字不能声明为变量名
    ['and', 'as', 'assert', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'exec', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'not', 'or', 'pass', 'print', 'raise', 'return', 'try', 'while', 'with', 'yield']

3、注意字符串必须用“”。。。。

4、注释

当行注视:# 被注释内容

多行注释:""" 被注释内容 """

5、if是判断语法,if 条件:......else:;if 条件:......elif 条件:.......else:。注意冒号和缩进!!!

6、print方法 

7、代码               

 1 a = 10  #变量赋值
 2 b = a+20
 3 c = a*b
 4 d = a-b
 5 print(d,c)
 6 
 7 name = "leon" #变量赋字符串
 8 name2 = name
 9 print(name,name2)
10 name = "xu"
11 print(name,name2)
12 print("我爱北京" )
13 
14 price_ball = 30
15 name = input("please input things name:")
16 num = input("please input bought number:")
17 if int(num)>=30:
18     print("Quantity of the goods is not enough ")
19 else:
20     print("You want to buy the",name,",The total Price",price_ball*int(num),"rmb")
21 
22 print ("hello Python")

 

posted @ 2019-10-22 09:47  天天公园  阅读(77)  评论(0)    收藏  举报