Home Backend Development Python Tutorial Inventory of common terms in Python

Inventory of common terms in Python

Aug 13, 2019 pm 06:02 PM
python 术语

Inventory of common terms in Python

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中最常见的一个函数
Copy after login

The output result is:

hello world
Copy after login

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']
Copy after login

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 &#39;str&#39;> abc
Copy after login

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 &#39;int&#39;>
Copy after login

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 &#39;int&#39;>
Copy after login

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 &#39;float&#39;>
<class &#39;float&#39;>
<class &#39;float&#39;>
Copy after login

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
Copy after login

13.NoneType:

The data type of the None object.

For example:

>>> print(type(None))
<class &#39;NoneType&#39;>
>>>
Copy after login

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
Copy after login

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(&#39;T&#39;)
else:
    print(&#39;F&#39;)
 if a is None:
    print(&#39;T&#39;)
 else:
     print(&#39;F&#39;)
输出结果为:
T
T
Copy after login

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内置常量
[&#39;True&#39;、&#39;False&#39;、&#39;None&#39;、&#39;NotImplemented&#39;、&#39;Ellipsis&#39;、&#39;__debug__&#39;]
Copy after login

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
Copy after login
hi="你好"
a="asd"
print(a)
print(hi)
>>asd
>>你好
Copy after login

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内置函数,不能设为变量
[&#39;and&#39;, &#39;as&#39;, &#39;assert&#39;, &#39;break&#39;, &#39;class&#39;, &#39;continue&#39;, &#39;def&#39;, &#39;del&#39;, &#39;elif&#39;, &#39;else&#39;, &#39;except&#39;, &#39;exec&#39;, &#39;finally&#39;, 
&#39;for&#39;, &#39;from&#39;, &#39;global&#39;, &#39;if&#39;, &#39;import&#39;, &#39;in&#39;, &#39;is&#39;, &#39;lambda&#39;, &#39;not&#39;, &#39;or&#39;, &#39;pass&#39;, &#39;print&#39;, &#39;raise&#39;, &#39;return&#39;, 
&#39;try&#39;, &#39;while&#39;, &#39;with&#39;, &#39;yield&#39;]
Copy after login

17. Assignment operator:
“=", defines a new value for a variable.

For example:

a="你好”
print(a)
输出结果:
你好
Copy after login

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
Copy after login

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
Copy after login

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
Copy after login

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!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1660
14
PHP Tutorial
1260
29
C# Tutorial
1233
24
PHP and Python: Different Paradigms Explained PHP and Python: Different Paradigms Explained Apr 18, 2025 am 12:26 AM

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

Choosing Between PHP and Python: A Guide Choosing Between PHP and Python: A Guide Apr 18, 2025 am 12:24 AM

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP and Python: A Deep Dive into Their History PHP and Python: A Deep Dive into Their History Apr 18, 2025 am 12:25 AM

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

Python vs. JavaScript: The Learning Curve and Ease of Use Python vs. JavaScript: The Learning Curve and Ease of Use Apr 16, 2025 am 12:12 AM

Python is more suitable for beginners, with a smooth learning curve and concise syntax; JavaScript is suitable for front-end development, with a steep learning curve and flexible syntax. 1. Python syntax is intuitive and suitable for data science and back-end development. 2. JavaScript is flexible and widely used in front-end and server-side programming.

How to run sublime code python How to run sublime code python Apr 16, 2025 am 08:48 AM

To run Python code in Sublime Text, you need to install the Python plug-in first, then create a .py file and write the code, and finally press Ctrl B to run the code, and the output will be displayed in the console.

Where to write code in vscode Where to write code in vscode Apr 15, 2025 pm 09:54 PM

Writing code in Visual Studio Code (VSCode) is simple and easy to use. Just install VSCode, create a project, select a language, create a file, write code, save and run it. The advantages of VSCode include cross-platform, free and open source, powerful features, rich extensions, and lightweight and fast.

Can visual studio code be used in python Can visual studio code be used in python Apr 15, 2025 pm 08:18 PM

VS Code can be used to write Python and provides many features that make it an ideal tool for developing Python applications. It allows users to: install Python extensions to get functions such as code completion, syntax highlighting, and debugging. Use the debugger to track code step by step, find and fix errors. Integrate Git for version control. Use code formatting tools to maintain code consistency. Use the Linting tool to spot potential problems ahead of time.

How to run python with notepad How to run python with notepad Apr 16, 2025 pm 07:33 PM

Running Python code in Notepad requires the Python executable and NppExec plug-in to be installed. After installing Python and adding PATH to it, configure the command "python" and the parameter "{CURRENT_DIRECTORY}{FILE_NAME}" in the NppExec plug-in to run Python code in Notepad through the shortcut key "F6".

See all articles