python第一周学习

Python第一周学习

1.Python支持命令式编程,函数式编程,面向对象设计

2.python是一种动态类型语言,变量的类型可以随时变化

>>>x=3
>>>print(type(x))  
<class 'int'>
>>>x='Hello World.'
>>>print(type(x))
<class 'str'>
>>>x=[1,2,3]
>>>print(type(x))
<class 'list'>

3.python中,允许多个变量指向同一个值,例如;

>>>x=3
>>>id(x)
>1786684560
>>>y=x
>>>id(y)
1786684560

4.输出函数print

print('Hello','World!')  #Hello World!
print(3,2,8)  #3 2 8
print(3,2,8, sep=',')   #3,2,8
print(8,26,18,sep=':')    #8:26:18``

Python输出str.format()
<模板字符串>format(<逗号分隔的参数>)
print(’{},{},{}’.format(‘Tom’,‘男’,40)

5.python输入:input()

input()函数:
print('Hello','World!')
s=input()
print("Hello",s)
print(input())
读入的字符串不能直接用于数学运算
s=input()  100
print(3*s)  100100100
a=input()  10
b=input()  50
print(a+b)   1050

6.python使用对象模型来存储数据,构造任何类型的值都是一个对象

7.range()语法格式为range(start,end,step)

>>>range(5)
range(0,5)
>>>list(range(5))
[0,1,2,3,4]
>>>liat(range(1,10,2))
[1,3,5,7,9]
>>>list(range(9,0,-2))
>[9,7,5,3,1]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值