1. Note:
There is a special symbol at the beginning of the line to tell the programmer to ignore this line at runtime; making the code easier to read.
For example:
#这是一个注释 print("hello world") #print() 方法用于打印输出,python中最常见的一个函数
The output result is:
hello world
2. Keywords:
Have special meaning in programming language word.
For example:
#使用keyword模块,可以输出当前版本的所有关键字 import keyword #import() 函数用于动态加载类和函数 。如果一个模块经常变化就可以使用 import() 来动态载入。 keyword.kwlist #在命令窗口中输出 >>> import keyword >>> keyword.kwlist ['False', 'None', 'True', 'and', 'as', 'assert', 'async', 'await', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'l ambda', 'nonlocal', 'not', 'or', 'pass', 'raise', 'return', 'try', 'while', 'with', 'yield']
3. Data type:
Divide data into different categories, and the category to which the data belongs is the data type.
Standard data types
There are six standard data types in Python3:
Number (number)
String (string)
List (list)
Tuple (tuple)
Set (set)
Dictionary (dictionary)
Six standard data types of Python3 Medium:
Immutable data (3): Number, String, Tuple;
Variable data (3): List ), Dictionary, Set.
4. Object:
A data value in Python that has 3 attributes - unique identification, data type and value.
(For example: if you want to kick a ball, the ball is an object, and the size, color, and price of the ball are the attributes of the ball.)
5.Str(string):
The data type of string.
For example:
#用type()查看数据类型 a="abc" print(type(a),a) 输出结果为: <class 'str'> abc
6. Characters:
For example: a, b, c,, 1, 2, 3 and other single symbols.
7.Int (inetrger):
The data type of integer.
For example:
a=1 # a=int("123") print(type(a)) 输出结果: <class 'int'>
8. Integer data:
An object whose data type is int and whose value is an integer value.
For example:
a=1 print(type(a)) 输出结果: <class 'int'>
Related recommendations: "Python Video Tutorial"
9.Float:
Decimal (a number with a decimal point).
For example:
s=1.0 w=0.1 e=8.9 print(type(s)) print(type(w)) print(type(e)) 输出结果: <class 'float'> <class 'float'> <class 'float'>
10. Floating point number:
An object whose data type is float, the value is a decimal value.
11.Bool:
Boolean value.
12. Boolean value:
An object whose data type is bool, the value is True or False.
For example:
a=1 b=2 print(a>b) print(a<b) 输出结果: False True
13.NoneType:
The data type of the None object.
For example:
>>> print(type(None)) <class 'NoneType'> >>>
14.None:
The value is always None, which is used to indicate missing data or to determine whether a variable is empty. It is the only value of NoneType.
For example:
a="" b="123" c=34 d=False e=[] print(a==None) print(b==None) print(c==None) print(d==None) print(e==None) 输出结果: False False False False False
It can be seen that from a type perspective, it is not equal to the empty string, not equal to the empty list, and not equal to False.
The correct judgment method is:
def fun(): #定义函数 return None a = fun() if not a: print('T') else: print('F') if a is None: print('T') else: print('F') 输出结果为: T T
15. Constant:
A value that will never change. (Including numbers, strings, Boolean values, and empty values. For example, the value of the number 1 is always 1)
For example:
#python内置常量 ['True'、'False'、'None'、'NotImplemented'、'Ellipsis'、'__debug__']
16. Variable:
You can use the assignment character "=" to perform the value assignment operation, and can be used to save any data type.
For example:
a=1, a is the name of the variable, and 1 is the value of the variable.
int q q=123 b=0 print(b) >>0 x=100 print(x) x=200 print(x) >>100 >>200
hi="你好" a="asd" print(a) print(hi) >>asd >>你好
Note:
1. Variable names cannot contain spaces.
2. Variable names can only use specific letters, numbers and underscores.
3. Variable names cannot start with numbers.
4. Keywords cannot be used as variable names
#以下属于python内置函数,不能设为变量 ['and', 'as', 'assert', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'exec', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'not', 'or', 'pass', 'print', 'raise', 'return', 'try', 'while', 'with', 'yield']
17. Assignment operator:
“=", defines a new value for a variable.
For example:
a="你好” print(a) 输出结果: 你好
18. Increase:
Increase the value of a variable.
For example:
a=1 a=a+1 print(a) >>2 或: x=1 x+=1 print(x) >>2
19. Reduce:
Reduce the value of a variable.
For example:
s=2 s=s-1 print(s) >>1 或: x=1 x-=1 print(x) >>0
20. Grammar:
The specification of language, a set of rules and processes for the order of words in a sentence.
21. Syntax error:
A fatal programming error caused by violating the grammar of the language.
22. Exception:
Non-fatal programming error.
23. Operator:
Symbols used with operators when expressing.
24. Arithmetic operators:
A type of operator in mathematical expressions. Such as: addition, subtraction, multiplication, division
#偶数 12%2 >>0 #奇数 11%2 >>1
25. Operands:
The values on both sides of the operator.
The above is the detailed content of Inventory of common terms in Python. For more information, please follow other related articles on the PHP Chinese website!

Pythonlistsareimplementedasdynamicarrays,notlinkedlists.1)Theyarestoredincontiguousmemoryblocks,whichmayrequirereallocationwhenappendingitems,impactingperformance.2)Linkedlistswouldofferefficientinsertions/deletionsbutslowerindexedaccess,leadingPytho

Pythonoffersfourmainmethodstoremoveelementsfromalist:1)remove(value)removesthefirstoccurrenceofavalue,2)pop(index)removesandreturnsanelementataspecifiedindex,3)delstatementremoveselementsbyindexorslice,and4)clear()removesallitemsfromthelist.Eachmetho

Toresolvea"Permissiondenied"errorwhenrunningascript,followthesesteps:1)Checkandadjustthescript'spermissionsusingchmod xmyscript.shtomakeitexecutable.2)Ensurethescriptislocatedinadirectorywhereyouhavewritepermissions,suchasyourhomedirectory.

ArraysarecrucialinPythonimageprocessingastheyenableefficientmanipulationandanalysisofimagedata.1)ImagesareconvertedtoNumPyarrays,withgrayscaleimagesas2Darraysandcolorimagesas3Darrays.2)Arraysallowforvectorizedoperations,enablingfastadjustmentslikebri

Arraysaresignificantlyfasterthanlistsforoperationsbenefitingfromdirectmemoryaccessandfixed-sizestructures.1)Accessingelements:Arraysprovideconstant-timeaccessduetocontiguousmemorystorage.2)Iteration:Arraysleveragecachelocalityforfasteriteration.3)Mem

Arraysarebetterforelement-wiseoperationsduetofasteraccessandoptimizedimplementations.1)Arrayshavecontiguousmemoryfordirectaccess,enhancingperformance.2)Listsareflexiblebutslowerduetopotentialdynamicresizing.3)Forlargedatasets,arrays,especiallywithlib

Mathematical operations of the entire array in NumPy can be efficiently implemented through vectorized operations. 1) Use simple operators such as addition (arr 2) to perform operations on arrays. 2) NumPy uses the underlying C language library, which improves the computing speed. 3) You can perform complex operations such as multiplication, division, and exponents. 4) Pay attention to broadcast operations to ensure that the array shape is compatible. 5) Using NumPy functions such as np.sum() can significantly improve performance.

In Python, there are two main methods for inserting elements into a list: 1) Using the insert(index, value) method, you can insert elements at the specified index, but inserting at the beginning of a large list is inefficient; 2) Using the append(value) method, add elements at the end of the list, which is highly efficient. For large lists, it is recommended to use append() or consider using deque or NumPy arrays to optimize performance.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Chinese version
Chinese version, very easy to use

SublimeText3 Linux new version
SublimeText3 Linux latest version

Dreamweaver Mac version
Visual web development tools

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.
