课时:一课时(45分钟)
课程内容:
1.type()函数的使用
2.类型转换函数的使用
3.input()函数的使用
课程安排:
(一)Python中的数据类型(基本型)
字符串型(str): “hello world” “我爱Python” "3+5"
整型(int): 5 5**2
浮点型(float):3.0 3.0*5
逻辑性(bool):True False
None型: None
(二)如何确定变量(值)的类型
type()函数: type(“hello world”)
运行程序,没有反应。记住:Python中使用print()函数进行输出,应写成: print(type(“helloworld”))
(三)类型装换
1.int():转换为整型
例如:int(3.9) 输出: 3 说明:int()只取整 ,不进行四舍五入
int(“10”) 输出:10 说明:输出没有变化,但是类型