cool hit counter python learning notes_Intefrankly

python learning notes


This post is A Byte of Python Study Notes

A Byte of Python eBook URL: https://python.swaroopch.com

data structure

Data Structures

There are four buit-in data structures in Python - list, tuple, dictionary and set.

List (mutable, changeable: add, delete, find)

Representation: [list1, list2, list3...]

help(list): see all functions and variables of list

Functions commonly used to manipulate lists.

append,add, shoppinglist.append('rice');

del, delete, del shoppinglist[0];

shoppinglist.sort(), sort list ;

len(shoppinglist), the number of elements to find the list;

Tuple Tuple (immutable immutable)

Note that a tuple within a tuple does not lose its identity.

Representation: (tuple1, tuple2, tuple3...)

single-element tuple=('apples', )

Dictionary

key cannot be changed, value can be changed

Representation:d=

key-value pairs in a dictionary are not order in any manner.

Sequence

List, tuple and strings are examples of sequence. The major feathers are membership test and and indexing operators.

slicing operation (two or three arguments)

Set

NOTE:When you create an object and assign it to a variable, the variable only refers to the object and does not represent the object itself ! That is, the variable name points to that part of your computer’s memory where the object is stored. This is called binding the name to the object.

An assignment statement for list does not create a copy.You have to use slicing operation to make a copy to the sequence.

help(str):View all variables and methods of the string

object-oriented programming

Object Oriented Programing

>Class and objects are the two main Aspects of object oriented programing.

>The fields and methods can be referred to as the attributes of that class.

>The fields are of two types: instance variables and class variables.

Creating classes, creating instances of classes

Methods for creating classes: Remember the back of the"()"

For example.

The __init__ method

Class and Object Vaviables

object variables: Owned by instances of the class

class variables: shared, can be used by all instances of the class

succeed

One of the major benefits of object oriented programming is reuse of code and one of the ways this is achieved is through the inheritance mechanism. Inheritance can be best imagined as implementing a type and subtype relationship between classes.

polymorphism

Examples of class and object variables (code can be slid left and right).

Caution.

population is a class variable, It's communal., Therefore when using"Robot.poplation"

name is an object variable, Therefore when using"self.name"

"@classmethod" is a modifier for class methods, method is a class method therefore when using "Robot.poplation"

Example of inheritance (code can be slid left or right).

Caution.

subcategoryTeacher,Student of the methods used in the succeed parent class, Therefore when using"class Teacher(SchoolMember):" harmony"class Student(SchoolMember):"

The methods of the subclass are used when"SchoolMember.tell(self)"

Objects of class: t, s form a list, implemented with a for loop

When no methods of the class are used, the object only calls the initialization of the class

What I discovered after this journey of learning is that it’s not the languages that matter but what you do with them. Actually, I always knew that, but I’d get distracted by the languages and forget it periodically. Now I never forget it, and neither should you.

Which programming language you learn and use doesn’t matter. Do not get sucked into the religion surrounding programming languages as that will only blind you to their true purpose of being your tool for doing interesting things.

---fromLearn Python 3 The Hard Way, Author,Zed A. Shaw


Recommended>>
1、The most commonly used string functions for php
2、Girl takes a shower at home gets webcast woman is so angry she jumps off a building without having time to put on her clothes
3、How convenient is it to book an appointment online The annual big data of Zhejiang appointment platform tells you
4、Blockchain over the fire 90yearold former gamer turned to chain people
5、Notice of the Department of Industry and Information Technology of Hainan Province on the organization of the declaration of the 2019 provinciallevel government information technology construction projects

    已推荐到看一看 和朋友分享想法
    最多200字,当前共 发送

    已发送

    朋友将在看一看看到

    确定
    分享你的想法...
    取消

    分享想法到看一看

    确定
    最多200字,当前共

    发送中

    网络异常,请稍后重试

    微信扫一扫
    关注该公众号