Escrito por estudiantes que aprobaron Inmediatamente disponible después del pago Leer en línea o como PDF ¿Documento equivocado? Cámbialo gratis 4,6 TrustPilot
logo-home
Resumen

Summary - Think Python book

Puntuación
-
Vendido
-
Páginas
26
Subido en
31-10-2023
Escrito en
2023/2024

Summary based on the book Think Python given in the course Python Programming for Geomatics (GEO1000)

Institución
Grado

Vista previa del contenido

Python Programming for Geomatics
(GEO1000)
Chapter 1: The way of the program

1.1 What is a program?
A program is a sequence of instructions that specifies how to perform a computation. The
details look different in different languages, but a few basic instructions appear in just about
every language:
 Input: get data from the keyboard, a file, the network, or some other device.
 Output: display data on the screen, save it in a file, send it over the network, etc.
 Math: perform basic mathematical operations like addition and multiplication.
 Conditional execution: check for certain conditions and run the appropriate code.
 Repetition: perform some action repeatedly, usually with some variation.

1.5 Values and types
A value is one of the basic things a program works with, like a letter or a number.

Name Example Type
Integer 2 int
Floating-point number 42.0 float
String ‘Hello, World!’ str

1.6 Formal and natural languages
 Natural languages: are the languages people speak, such as English, Spanish and
French. They were not designed by people they evolved naturally.
 Formal languages: are languages that are designed by people for specific applications.
For example, the notation that mathematicians use in a formal language that is
particularly good at denoting relations among numbers and symbols. Formal languages
tend to have strict end to have strict syntax rules that govern the structure of statements.

Programming languages are formal languages that have been designed to express
computations.

1.7 Debugging
Programmers make mistakes. For whimsical reasons, programming errors are called bugs
and the process of tracking them down is called debugging.

1.8 Glossary
 Problem solving: The process of formulating a problem, finding a solution, and
expressing it.
 High-level language: A programming language like Python that is designed to be easy for
humans to read and write.
 Low-level language: A programming language that is designed to be easy for a computer
to run: also called “machine language” or “assembly language”.
 Portability: A property of a program that can run on more than one kind of computer.
 Interpreter: A program that reads another program and executes it.

, Prompt: Characters displayed by the interpreter to indicate that it is ready to take input
from the user.
 Program: A set of instructions that specifies a computation.
 Print statement: An instruction that causes the Python interpreter to display a value on
the screen.
 Operator: A special symbol that represents a simple computation like addition,
multiplication, or string concatenation.
 Value: One of the basic units of data, like a number or string, that a program manipulates.
 Type: A category of values. The types we have seen so far are integers (type int),
floating-point numbers (type float), and strings (type str).
 Integer: A type that represents whole numbers.
 Floating-point: A type that represents numbers with fractional parts.
 String: A type that represents sequences of characters.
 Natural language: Any one of the languages that people speak that evolved naturally.
 Formal language: Any one of the languages that people have designed for specific
purposes, such as representing mathematical ideas or computer programs; all
programming languages are formal languages.
 Token: One of the basic elements of the syntactic structure of a program, analogous to a
word in a natural language.
 Parse: To examine a program and analyze the syntactic structure.
 Bug: An error in a program.
 Debugging: The process of finding and correcting bugs.


Chapter 2: Variables, expressions and statements

2.1 Assignment statements
A common way to represent variables on paper is to write the name with an arrow pointing to
its value. This is called a state diagram.

2.2 Variable names
Variable names can’t begin with a
number. Python has special keywords
reserved which cannot function as variable names.

False class finally is return
None continue for lambda try
True def from nonlocal while
and del global not with
as elif if or yield
assert else import pass
break except in raise

2.3 Expressions and statements
An expression is a combination of values, variables and operators. A value all by itself is
considered an expression and so is a variable. A statement is a unit of code that has an
effect, like creating a variable or displaying a value.

, 2.5 Order of operations
When an expression contains more than one operator, the order of evaluation depends on
the order of operations. For mathematical operators, Python follows mathematical convention
(acronym: PEMDAS):
- Parentheses
- Exponentiation
- Multiplication, division, addition and subtraction.

2.6 String operations
The + operator performs string concatenation, which means it joins the strings by linking
them end-to-end. For example:
first = ‘throat’
second = ‘warbler’
first + second
throatwarbler

The ∗ operator also works on strings; it performs repetition. For example: ‘Spam’ ∗3 is
‘SpamSpamSpam’.

2.7 Comments
As programs get bigger and more complicated, they get more difficult to read. For this
reason, it is a good idea to add notes to your programs to explain in natural language what
the program is doing. These notes are called comments and they start with the # symbol.

2.8 Debugging
Three kinds of errors can occur in a program: syntax errors, runtime errors and semantic
errors.
 Syntax error: ‘Syntax’ refers to the structure of a program and the rules about that
structure. For example: 1 + 2) is a syntax error.
 Runtime error: A runtime error does not appear until after the program has started
running. These errors are also called exceptions because they indicate that something
exceptional (and bad) has happened.
 Semantic error: If there is a semantic error your program will run without generating error
messages, but it will not do the right thing.

2.9 Glossary
 Variable: A name that refers to a value.
 Assignment: A statement that assigns a value to a variable.
 State diagram: A graphical representation of a set of variables and the values they refer
to.
 Keyword: A reserved word that is used to parse a program; you cannot use keywords like
if, def and while as variable names.
 Operand: One of the values on which an operator operates.
 Expression: A combination of variables, operators and values that represents a single
result.
 Evaluate: To simplify an expression by performing the operations in order to yield a single
value.
 Statement: A section of code that represents a command or action.
 Execute: To run a statement and do what it says.
 Interactive mode: A way of using the Python interpreter by typing code at the prompt.

Libro relacionado

Escuela, estudio y materia

Institución
Estudio
Grado

Información del documento

¿Un libro?
No
¿Qué capítulos están resumidos?
1-17
Subido en
31 de octubre de 2023
Número de páginas
26
Escrito en
2023/2024
Tipo
RESUMEN

Temas

$5.93
Accede al documento completo:

¿Documento equivocado? Cámbialo gratis Dentro de los 14 días posteriores a la compra y antes de descargarlo, puedes elegir otro documento. Puedes gastar el importe de nuevo.
Escrito por estudiantes que aprobaron
Inmediatamente disponible después del pago
Leer en línea o como PDF

Conoce al vendedor

Seller avatar
Los indicadores de reputación están sujetos a la cantidad de artículos vendidos por una tarifa y las reseñas que ha recibido por esos documentos. Hay tres niveles: Bronce, Plata y Oro. Cuanto mayor reputación, más podrás confiar en la calidad del trabajo del vendedor.
epsilon Hogeschool Rotterdam
Seguir Necesitas iniciar sesión para seguir a otros usuarios o asignaturas
Vendido
19
Miembro desde
7 año
Número de seguidores
16
Documentos
7
Última venta
2 año hace

4.0

1 reseñas

5
0
4
1
3
0
2
0
1
0

Documentos populares

Recientemente visto por ti

Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes