Home >Backend Development >Python Tutorial >[shared-reading] Learn Basic Python Book - Quick and Easy to Understand

[shared-reading] Learn Basic Python Book - Quick and Easy to Understand

WBOY
WBOYOriginal
2024-08-18 06:25:32702browse

1. Introduction

Pages 8 to 18.

Python is a popular language, easy to use, easy to read, multiple functions (web, data analysis, desktop, backend, etc.).

Python is currently in version 3 and this is the version that receives the updates.

The Anaconda distribution of Python has several packages used in scientific programming, data analysis, etc. It also has an IDE (Integrated Development Environment) and several other features.

Link to Anaconda Download

After installation, you must check whether it was installed correctly by typing Python or in some cases Python3 into the computer terminal. This way we will have something similar to the screen below:

[leitura-compartilhada] Livro Aprenda Python Básico - Rápido e Fácil de Entender

In this prompt we can type language commands and see outputs.
print("Hi")

[leitura-compartilhada] Livro Aprenda Python Básico - Rápido e Fácil de Entender

To exit this terminal we can type exit() and press ENTER

When installing the Anaconda distribution, the spyder IDE is also installed but the puthon code can be run from another IDE or preferred Text Editor.

To open Spyder, I first needed to start Anaconda Navigator, but when trying to open Spyder, I believe that due to some problem related to my machine's operating system, I was unable to open it in sequence. As I already have VS Code installed, I intend to use it to perform the exercises in the book.

We can execute python codes by directly entering commands in the terminal or through .py files.

In the second example of the book, you are asked to create a file called oi_python.py and type the code print ("Hi, Python") inside it and save. After saving, to execute you must open the terminal, navigate to the folder, if necessary, and execute the python command oi_python.py

To navigate to the folder we can use the cd command

When executed, it will produce the result below:
[leitura-compartilhada] Livro Aprenda Python Básico - Rápido e Fácil de Entender

In more complex projects, .py files are used

Example of other code:

nome = input("Digite aqui o seu nome: ")
print("Olá, %s" % nome)

Typing the code can help with recording but in any case the entire book code can be found at this link


2. Print, Comments and Data Types

_Pages 19 to _

Functions are predefined blocks or pieces of code that can be reused. They can take parameters or not.

The functions can return a value or display some information, the value that can be returned can be used for some other purpose.

Parameters are information passed to the function that must be used to perform some action (calculation or processing).

Function example:
print("The print function, for example, receives as a parameter what will be displayed by it.")

How to identify a function?

A function is called by its name followed by parentheses. Some parameter may or may not be passed inside these parentheses depending on the function.

In Python version 2 it was possible to use print as follows: print "Hi, Python" but this is not accepted in version 3.

In the code of a python file we can add comments using the # symbol command, this way the line with this symbol will not be executed. The comments serve to illustrate,
explain or include additional information.

# esta linha não será executada
print("esta linha será executada")

The above is the detailed content of [shared-reading] Learn Basic Python Book - Quick and Easy to Understand. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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