- 博客(9)
- 收藏
- 关注
原创 面向对象编程OOP 2&3
实例一: import datetime class Student: def __init__(self,name,birthdate): self.name = name self.birthdate = birthdate @property def age(self): return datetime.date.d...
2020-02-22 14:14:50
133
原创 函数与Lambda表达式
函数传递 #*score是一个元组,说明可能有很多门成绩 def avg(*scores): return sum(scores)/len(scores) result= avg(98.2,88.1,70,65) print(result) emp={ 'name':'TOM', 'age':22, 'job':'dev' } def display(**e...
2020-02-20 20:12:28
440
原创 迭代、函数笔记
函数map() def double_number(x): return x* 2 l=[1,2,3,4,5] result =list(map(double_number,l)) print(result) #此map()函数指的是把l里的值都放到double_number这个函数里操作 函数定义及调用 #定义函数 def read_book(): print('拿到一本书'...
2020-02-19 15:25:24
174
原创 while语句作业
1.用户登录程序需求: 输入用户名和密码。 判断用户名和密码是否正确,(name=‘root’,password=‘westos’) 登录仅有三次机会,如果登陆次数大于三次,不包括三次,那么就报错提示。 trycount=0 while trycount<3: name=input('用户名:') password=input('密码:') if name =='ro...
2020-02-18 19:47:34
205
原创 if while for 循环
while循环 一般循环: x='youpinketang' while x: print(x,end=' ') x=x[1:] a,b=0,10 while a<b: print(a) a+=1 #a+=1 即a不断加1 while循环 continue: #要求要打印偶数 x=10 while x: x-=1 if x %2 ...
2020-02-18 16:38:33
247
原创 Python每日作业3
In[2]: d={‘ISBN’:‘23412343’,‘Title’:‘Python 入门’,‘Price’:29.00} In[3]: d Out[3]: {‘ISBN’: ‘23412343’, ‘Title’: ‘Python 入门’, ‘Price’: 29.0} In[4]: d[‘Price’] Out[4]: 29.0 In[5]: d[‘Author’]=‘Jerry’ In[6...
2020-02-17 16:34:50
833
原创 python作业2
l=[1,‘abc’,[2,3,4]] len(1)(意思是说这个组的长度是多少) d.get(‘name’)(类似查找的一个程序) tuple是()不可修改 list是[ ] 可修改 format是个传递的程序eg:’{0}’.format(20)'20’若希望保留两位小数 则写 :.2f 判断是否相等用== 判断不等于则用!= 双斜杠是指除以取整 math.floor() 左向取整的函数 ...
2020-02-16 15:05:32
698
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅