python实践课 1

>>> 11+22
33
>>> _+3
36
>>> print('hello,world')
hello,world
>>> 2,2**10
(2, 1024)
>>> print('hello'*3)
hellohellohello
>>> for x in range(10):
	print(x, end = ' ')

	
0 1 2 3 4 5 6 7 8 9 
>>> abs
<built-in function abs>
>>> id(abs)
33358848
>>> type(abs)
<class 'builtin_function_or_method'>
>>> 
>>> 123	//直接创建对象
123
>>> int(123)//调用类对象创建实例对象
123
>>> complex(1,2)//创建复数实例对象
(1+2j)
>>> 5//3//整除
1
>>> a = 1//字面量表达式创建值为1int型实例对象,并绑定到变量a
//对象的函数和类也可以通过变量引用。如下:abs是一个函数 下面等同于abs-123>>>> x = (abs)	
>>> x(-123)
123		
//通过标识符和赋值运算符(=)可以指定某个变量指向某个对象,即引用该对象。如下:a,b指向同一个对象
>>> a = 123		
>>> b = 123
>>> id(a)
8791349667296
>>> id(b)
8791349667296
//python是强类型语言	intstr类型不能直接相加,str不会自动转换为int
>>> a = 1
>>> b = "11"
>>> a+b
Traceback (most recent call last):
  File "<pyshell#21>", line 1, in <module>
    a+b
TypeError: unsupported operand type(s) for +: 'int' and 'str'
>>> 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值