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!")
温馨提示:本文最后更新于
转载请注明本文链接:https://blog.leonshadow.cn/763482/1167.html
2022-12-20 20:57:48
,已超过486
天没有更新。某些文章具有时效性,若文章内容或图片资源有错误或已失效,请联系站长。谢谢!转载请注明本文链接:https://blog.leonshadow.cn/763482/1167.html
© 版权声明
THE END