1.1 入门
1.1.1 第一个hello word程序
print("Hello World!")
1.1.2 注释方法
# 单行注释 '''块注释''' """块注释"""
1.1.3 变量赋值
Python中只有变量,没有常量,即所有的变量都是可变的,程序中经常把“常量”定义为全部大写字符
# 变量赋值运算 x = 3 y = 4 z = x * y print("x*y =",z) # 常量定义 COUNTNUM = 50
1.1.4 用户输入
注意:用户所有的输入都是字符串类型
name = input("Please input your name:") age = input("Please input your age:") print("Your name is:"+name+" and your age is:"+age)
1.1.5 字符串拼接
maxNum = 80 inputNum = input("Please input your number:") print("There is "+str(maxNum-int(inputNum))+" in different")
1.2 条件语句
1.2.1 if条件语句
maxNum = 80 inputNum = input("Please input your number:") if maxNum-int(inputNum)>0: print("Please input bigger...") elif maxNum-int(inputNum)<0: print("Please input smaller...") else: print("You have guess the number!")

我的微信
如果有技术上的问题可以扫一扫我的微信