最近研究函数、数据-,稍微总结一下,以后继续补充:
面下是应用Array现实Vector.也就是Python中自带的list().
代码如下:
class Vector: def __init__(self): self._length = 0 self._capacity = 2 self._array = Array(self._capacity) def __len__(self): return self._length def __contains__(self,item): for v in self: if v == item: return True return False def __getitem__(self,index): return self._array[index] def __setitem__(self,index,value): self._array[index] = value def __new_array(self): oldCap = self._capacity newCap = self._capacity * 2 newArray = Array(newCap) for i,v in enumerate(self._array): newArray[i] = v self._array = newArray self._capacity = newCap def append(self,item): if self._length == self._capacity: self.__new_array() self._array[self._length] = item self._length += 1 def insert(self,ndx,item): if self._length == self._capacity: self.__new_array() for i in range(self._length,ndx,-1): self[i] = self[i-1] self._array[ndx] = item self._length += 1 def remove(self,ndx): for i in range(ndx,self._length): self[i] = self[i+1] self._length -= 1 def indexOf(self,item): for i,v in enumerate(self): if v == item: return i return -1 def extend(self,otherVector): for v in otherVector: self.append(v) def subVector(self,f,t): newV = Vector() for i in range(f,t): newV.append(self._array[i]) return newV def __iter__(self): return _VectorIterator(self) class _VectorIterator: def __init__(self,theVector): self._vectorRef = theVector self._curNdx = 0 def __iter__(self): return self def next(self): if self._curNdx < len(self._vectorRef): entry = self._vectorRef[self._curNdx] self._curNdx += 1 return entry else: raise StopIteration
测试基本是跟list一样.
旁边涉及到一个小东东.想要在Python隐藏函数,数据.只需要在前面加上`__`以可就了.当然数据,函数还在.只是换了一个名字而已.详细可以看<Python级高程编>(记得..).
睡觉先...
文章结束给大家分享下程序员的一些笑话语录: 某程序员对书法十分感兴趣,退休后决定在这方面有所建树。花重金购买了上等的文房四宝。一日突生雅兴,一番磨墨拟纸,并点上了上好的檀香,颇有王羲之风 范,又具颜真卿气势,定神片刻,泼墨挥毫,郑重地写下一行字:hello world.
相关推荐
问答互动引出学习目标 讲授法 示范练习 随堂报告 Python-Python函数-教学设计全文共6页,当前为第1页。Python-Python函数-教学设计全文共6页,当前为第1页。《Python函数》教学设计 Python-Python函数-教学设计全文...
最小二乘法线性函数模型 - python实现 对应博客文章链接随后发布!
Python课程2.1-使用numpy和pandas实现金融数据的高效计算.pdf Python课程2.2-Matplotlib可视化:绘制2D和3D图.pdf Python课程3.1-爬虫环境配置与简单爬取程序实现.pdf Python课程3.2-典型爬虫程序的实现(1).pdf ...
数据处理Pandas-如何实现Excel多表合井(concat()函数)-Python实例源码.zip
8 越疆-Dobot-Python编程与机器人 第八章 函数(共1课时).docx8 越疆-Dobot-Python编程与机器人 第八章 函数(共1课时).docx8 越疆-Dobot-Python编程与机器人 第八章 函数(共1课时).docx8 越疆-Dobot-Python编程与...
Python科学计算与数据处理-Python函数.ppt
Python课程2.1-使用numpy和pandas实现金融数据的高效计算.pdf Python课程2.2-Matplotlib可视化:绘制2D和3D图.pdf Python课程3.1-爬虫环境配置与简单爬取程序实现.pdf Python课程3.2-典型爬虫程序的实现(1).pdf ...
Python课程2.1-使用numpy和pandas实现金融数据的高效计算.pdf Python课程2.2-Matplotlib可视化:绘制2D和3D图.pdf Python课程3.1-爬虫环境配置与简单爬取程序实现.pdf Python课程3.2-典型爬虫程序的实现(1).pdf ...
python学习笔记,包含一般函数-向量化函数-二元运算-ufunc对象
Python课程2.1-使用numpy和pandas实现金融数据的高效计算.pdf Python课程2.2-Matplotlib可视化:绘制2D和3D图.pdf Python课程3.1-爬虫环境配置与简单爬取程序实现.pdf Python课程3.2-典型爬虫程序的实现(1).pdf ...
基本元素 Python语法特点 标识符与变量、常量 基本数据类型 基本输入和输出 常见的运算符与表达式 第二章 Python基本语法 参考书目《Python 程序设计》 第2章-Python基本语法-Python程序设计基础案例教程-李辉-清华...
python类和函数教程_python基础教程:类 Python是⾯向对象的⾼级编程语⾔,在Python⾥⾯"⼀切都是对象":数字、字符串、元组、列表、字典、集合等内置数据类型,以及函 数、⽅法、类、模块都是对象。 语⾔本⾝提供了...
第五章-python中的函数与模块-青少年编程练习测试题及答案解析全文共5页,当前为第1页。第五章-python中的函数与模块-青少年编程练习测试题及答案解析全文共5页,当前为第1页。第五章 python中的函数与模块 第五章-...
15位或18位身份证号码检查,python库,
Python课程2.1-使用numpy和pandas实现金融数据的高效计算.pdf Python课程2.2-Matplotlib可视化:绘制2D和3D图.pdf Python课程3.1-爬虫环境配置与简单爬取程序实现.pdf Python课程3.2-典型爬虫程序的实现(1).pdf ...
python学习笔记,包含choose 函数实现条件筛选-数组广播机制-数组读写-结构化数组
理解Pandas中两种主要的数据结构。 掌握Pandas中选取数据的方法。 掌握Pandas中修改、增加和删除数据的方法。 Python数据分析与应用案例教程-第2章--Python数据分析基础全文共79页,当前为第3页。 Python数据分析
基准测试函数,python
Python课程2.1-使用numpy和pandas实现金融数据的高效计算.pdf Python课程2.2-Matplotlib可视化:绘制2D和3D图.pdf Python课程3.1-爬虫环境配置与简单爬取程序实现.pdf Python课程3.2-典型爬虫程序的实现(1).pdf ...