Python第一天

代码示例
heroList = ['0', "1", "2", '3', 100, 10.1]
print(heroList)
print("为:",heroList[1],heroList[0])
heroList.append('6') #在列表的末尾进行添加元素
heroList[4] = "4" #修改列表中指定位置的元素
del heroList[5] #删除列表中指定位置的元素

Python中的变量
a = 100 # 不用声明变量的类型 ,不用写;

Python中的语句
判断语句
格式
if 要判断的条件:
满足条件时要执行的事情
if(age >= 18:){
恭喜你成年了,可以去网吧了
}
age = input('请输入您的年龄')
age = 3
print(type(age)) # 转换成数字类型
age = int(age)
print(type(age))
if age >= 18:
print("恭喜你成年了,可以去网吧了")
else:
print('sorry,你还是个宝宝')

你可能感兴趣的:(Python第一天)