Install, compile and run

Python is easy to install by going to www.python.org/. Ub… Install python. Windows directly download the MSI package to install. Python programs are executed through an interpreter, so once installed, you can see that Python provides two parsers, one IDLE (Python GUI) and one Python (Command line). The former is a version with a GUI interface, while the latter is virtually the same as running Python at a command prompt. After running the interpreter, there is a command prompt >>> at which you type your program statement, which will be executed immediately. Just like Matlab.

In addition, Matlab has a.m step file, and Python also has a.py script file, which in addition to explaining execution, can also be compiled and run, which is faster than explaining execution.

For example, I want to print a helloWorld.

Method 1: Directly in the interpreter, >>> print ‘helloWorld’.

Method 2: Write this code to a file, such as hello.py. There are three ways to run this file:

1) In the terminal: python hello.py

2) Compile to a. Pyc file first:

import py_compile

py_compile.compile(“hello.py”)

Again in terminal: Python hello.pyc

3) In the terminal:

python -O -m py_compile hello.py

python hello.pyo

When compiled into. Pyc and. Pyo files, execution is faster. So code that is repetitive and called many times will be compiled to be called in either of these executable ways.

Variables, operations and expressions

There’s nothing to talk about here, and programming in other languages is no problem. The similarity with Matlab is relatively large. That’s not a big difference. Details are as follows:

One thing to note: 5/2 is equal to 2. 5.0/2 is equal to 2.5.

Data types

1, Numbers,

The usual int, long,float,long, and so on are supported. And it depends on your specific number to define the type of variable. As follows:

2. Strings

Single, double, and triple quotation marks can all be used to define strings. Triple quotes define specially formatted strings. As a sequence type, string supports index access and slice access like Matlab.

3, yuan group

The tuple tuple is defined by (). It’s an array that can store different types of data. It can be accessed using an index, but it is important to note that the elements inside cannot be modified.

4, list

List list is defined with []. It functions the same as a tuple, except that the elements can be modified. List is a class that supports a number of methods defined by that class that can be used to operate on a List.

5, the dictionary

The dictionary is defined with {}. It has the advantage of defining key-value pairs like key-values, just as struct structures do. It also supports creation and manipulation of methods supported by the dictionary class.

If you do meet a good coworker, you’ll be lucky. Come on! Q Group :766610200 Includes Python, PythonWeb, crawler, data analysis and other Python skills, as well as artificial intelligence, big data, data mining, automation and other learning methods. Build from zero to the project development hands-on combat all-round analysis!

Click: Join