python的第一个代码
print(“hi”)
注释
单行注释使用#,快捷键为ctrl+/
多行注释3个为"注释内容"一般写在文档开头
变量的使用
使用变量首先得先定义
变量的类型
int 整形 age=10
float 浮点型 height=182.1
str 字符串 name=“lisha”
dist 列表 list1=[‘1’,‘2’,‘3’]
tuple 元组 tuple1=(“1”,“2”,“3”)
dict 字典 dict 1= {‘a’: 1, ‘b’: 2, ‘b’: ‘3’}
输入函数input
在代码运行时需要键盘输入
其中input输入的内容都是字符串类型str,可以使用type()函数进行查看数据类型,我们在使用时需注意类型转换,例如在这里我需要对年龄进行+1时就需要转化为age=int(age)+1