p01

1. 五种基本对象类型:

字符串:str,使用‘ ’或“ ”括起来的一系列字符

整数:int,十进制:21,八进制:025,十六进制:0x15

浮点数:float,1.65,21.0,21.,.21,2.1E1

布尔值:bool,True,False

复数:complex,1+1j

2. type('奶茶') -> <type 'str'>

3. 强制类型转换

int('123') -> 123

str(123) -> '123'

float('123') -> 123.0

float(123) -> 123.0

bool(123) -> True

bool(0) -> False

4. 算术运算符:+, -, *, /, %, **(指数);

5. 参与运算的两个对象的类型不同,按照以下规则进行自动类型转换:

bool -> int -> float -> complex

6. 模块(module):实现一定功能的Python脚本集合;

引入模块:import module_name

math模块:import math,查看模块内容:dir(math),查看帮助:help(math.sin)

7. 逻辑运算符:and, or, not

8. 判断闰年,如果年份能被4整除不能被100整除,或者能被400整除,则为闰年:(y%4 == 0 and y%100 != 0) or (y%400 == 0)

9. raw_input函数:

功能:读取键盘输入,将所有输入作为字符串看待

语法:raw_input([prompt]),[prompt]是提示符,最好提供

eg:radius = float(raw_input('Radius: '))

10. print 'The area for the circle of radius', radius, 'is',area

print 'Hello\nWorld!'

11. grade = 60;

if grade > 50:

print 'hello'

elif grade > 40:

print 'pp'

else:

pass

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值