Mengran's Blog

「We spent our lives making a living」

Python Basics 6: Class & Object-oriented Programming(OOP)

Definition of OOP, Class and Instance

Class and Instance Class(类): A Class is like an object constructor. A user-defined prototype for an object that defines a set of attributes that characterize any object of the class. The attribut...

Leetcode Exercise: Array

Array related Qs

Max Consecutive Ones Given a binary array nums, return the maximum number of consecutive 1’s in the array. Example 1: Input: nums = [1,1,0,1,1,1] Output: 3 Explanation: The first two digits or...

Python Basics 5: Function, Lambda

Definition of Function, Lambda

Definition of Function Definition: 函数 function 是对程序逻辑进行结构化的一种编程方法 函数代码块以 def 关键词开头,后接函数标识符名称和圆括号 在圆括号()里是传进来的参数 parameter,然后通过 return 进行函数结果得反馈。 Syntax: 1 2 3 4 5 6 def 函数名称(): code bloc...

Python Basics 4: Exception & Error

How to handle Exception and Error

Exception & Error Key points: Error is not equal to Exception Exception 异常 是在出现错误时采用正常控制流以外的动作 How to handle Exception: Detected error, thus triggering exception 检测到错误,引发异常 Catch t...

Python Basics 3: File Handling - Input & Output

How to input & output files with Python

Files Input & Output Files Built-in Functions: open() - 打开文件 open a file read() - 输入 read/input a file readline() - 输入一行 read/input a line seek() -文件内移动 look for write() -输出 output...

Python Basics 2: Built-in Data Types & Loop

Definition of Array, String, List, Dictionary, Loop etc

Python Built-in Data Types Variables can store data of different types, and different types can do different things. Lists Tuple Set Dictionary Array 序列 Definition: Arrays are used to...

Python Basics 1: Class, Object, Variables, Modules, Packages

Definition of Class, Object, etc

Class & Instance 在专业术语上,我们将类别称做类型(class),而个体叫做实例(instance)。 存活的实例对象都有个 “唯一” 的 ID 值。 可用 type 返回实例所属类型。 如要判断实例是否属于特定类型,须用 isinstance 函数。 1 issubclass(Liger, object) 事实上,所有类型都有一个共同祖先类型 obje...

First Article for Test

Test to see if it's working

Take it easy, it’s just a test! 「Test is fun」: 「We all need a test」Nodmcjendjdjja ddjdjjdjdebc google 「Hello guys」