Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the basic knowledge points of Python

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces the relevant knowledge of "what are the basic knowledge points of Python". In the operation of actual cases, many people will encounter such a dilemma. Next, let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Introduction to python

Python is an object-oriented interpretive computer programming language. Python was invented by Guido Van Rosum (Guido van Rossum) in 1989.

Any language has its advantages and disadvantages, python is no exception, the advantages of python is easy to understand, portability, scalability, embeddedness, the disadvantages of python, one is slow, because python is an interpreted language, the code in the execution process will be a line of translation into cpu can understand the machine code; second, the code can not be encrypted, if you want to release the python program, is actually the release of source code.

Python is cross-platform, and it can run on Windows, Linux and Mac systems. To start learning python programs, you first need to install python on your computer and download the software version you need to install from python's official website. After installation under www.python.org and Windows systems

Python basic notes

Call python,exit () exit through the cmd command

The first python program

Execute the program through the python interactor, and finally exit the python with exit (). Our first python program is completed, but the only drawback is that it is not saved, and we need to type the code again next time. Python Learning qun [784758214] has installation packages and learning video materials, zero basic, advanced, practical free online live broadcast free course, hope to help you quickly understand Python, learn python

Python basic notes

You can output the specified text to the screen by adding a string in parentheses with print ()

If you write a program on the python interactive command line, the advantage is that you can get the result at once, but the disadvantage is that you can't save it, so in actual development, we will use IDE or a text editor to write the code, and save it as a python file, so that the program can run repeatedly, create a hello.py file, and enter print ("hello world").

Python basic notes

Open the program by entering the specified directory and using the python hello.py command

Variable

The rules for defining variables in python are

Variable names can only be any combination of letters, numbers, or underscores

The first character of a variable name cannot be a number

Keywords in python cannot be declared as variable names

Define variable

Name = "Zyy"

The above code declares a variable named name, and the value of the variable name is: "Zyy"

Input and output of python

By adding a string in parentheses with print (), you can output the specified text to the screen

Print () can accept multiple strings, separated by commas "," can be connected into a string, print () will print each string in turn, encounter a comma will output a space, print () can also print integers, or calculation results, can also be used in combination

Python basic notes

Print () output

Input characters using input ()

Python basic notes

Input () input

Data type of python

You can use the internal function type () to view the type of data

String (str)

Integer type (int)

Boolean (bool)

Floating point (float)

List (list)

Tuple (tuple)

Dictionary (dict)

Collection (set)

Null value (None)

Operator

Arithmetic operation + addition-subtraction * multiplication / division (when used / divided, the result is of type float) / / floor division (result is integer int)% take remainder * * power (2 times 2 represents the result of 2 to the second power 4)

Comparison operation, the output result is bool== equal to! = not equal to (not allowed to write after python3.0) > greater than

< 小于 >

= greater than or equal to

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report