100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Presentation

Think Python, 3rd Edition

Rating
-
Sold
-
Pages
304
Uploaded on
09-08-2024
Written in
2017/2018

"Python is an excellent way to get started in programming, and this clear, concise guide walks you through Python a step at a time—beginning with basic programming concepts before moving on to functions, data structures, and object-oriented design. This revised third edition reflects the growing role of large language models (LLMs) in programming and includes exercises on effective LLM prompts, testing code, and debugging skills. With this popular hands-on guide at your side, you'll get: A grounding in the syntax and semantics of the Python language A clear definition of each programming concept, with emphasis on clear vocabulary How to work with variables, statements, functions, and data structures in a logical progression Techniques for reading and writing files and databases A solid understanding of objects, methods, and object-oriented programming Debugging strategies for syntax, runtime, and semantic errors An introduction to recursion, interface design, data structures, and basic algorithms How to use LLMs—including effective prompts, testing code, and debugging And more"

Show more Read less
Institution
Course











Whoops! We can’t load your doc right now. Try again or contact support.

Written for

Course

Document information

Uploaded on
August 9, 2024
Number of pages
304
Written in
2017/2018
Type
Presentation
Person
Unknown

Subjects

Content preview

,Chapter 1. Programming as a Way of
Thinking
The first goal of this book is to teach you how to program in Python. But learning to program
means learning a new way to think, so the second goal of this book is to help you think like a
computer scientist. This way of thinking combines some of the best features of mathematics,
engineering, and natural science. Like mathematicians, computer scientists use formal languages
to denote ideas—specifically computations. Like engineers, they design things, assembling
components into systems and evaluating trade-offs among alternatives. Like scientists, they
observe the behavior of complex systems, form hypotheses, and test predictions.

We will start with the most basic elements of programming and work our way up. In this chapter,
we’ll see how Python represents numbers, letters, and words. And you’ll learn to perform
arithmetic operations.

You will also start to learn the vocabulary of programming, including terms like operator,
expression, value, and type. This vocabulary is important—you will need it to understand the rest
of the book, to communicate with other programmers, and to use and understand virtual assistants.


Arithmetic Operators
An arithmetic operator is a symbol that represents an arithmetic computation. For example, the
plus sign, +, performs addition:


30 + 12


42


The minus sign, –, is the operator that performs subtraction:


43 - 1


42


The asterisk, *, performs multiplication:


6 * 7

,42


And the forward slash, /, performs division:





42.0


Notice that the result of the division is 42.0 rather than 42. That’s because there are two types of
numbers in Python:

 integers, which represent whole numbers, and
 floating-point numbers, which represent numbers with a decimal point.

If you add, subtract, or multiply two integers, the result is an integer. But if you divide two integers,
the result is a floating-point number. Python provides another operator, //, that performs integer
division. The result of integer division is always an integer:


84 // 2


42


Integer division is also called “floor division” because it always rounds down (toward the “floor”):


85 // 2


42


Finally, the operator ** performs exponentiation; that is, it raises a number to a power:


7 ** 2


49


In some other languages, the caret, ^, is used for exponentiation, but in Python it is a bitwise
operator called XOR. If you are not familiar with bitwise operators, the result might be unexpected:

, 7 ^ 2


5


I won’t cover bitwise operators in this book, but you can read about them
at http://wiki.python.org/moin/BitwiseOperators.


Expressions
A collection of operators and numbers is called an expression. An expression can contain any
number of operators and numbers. For example, here’s an expression that contains two operators:


6 + 6 ** 2


42


Notice that exponentiation happens before addition. Python follows the order of operations you
might have learned in a math class: exponentiation happens before multiplication and division,
which happen before addition and subtraction.

In the following example, multiplication happens before addition:


12 + 5 * 6


42


If you want the addition to happen first, you can use parentheses:


(12 + 5) * 6


102


Every expression has a value. For example, the expression 6 * 7 has the value 42.


Arithmetic Functions
$4.99
Get access to the full document:

100% satisfaction guarantee
Immediately available after payment
Both online and in PDF
No strings attached

Get to know the seller
Seller avatar
RobertCuong

Get to know the seller

Seller avatar
RobertCuong Telecommunication
Follow You need to be logged in order to follow users or courses
Sold
0
Member since
2 year
Number of followers
0
Documents
225
Last sold
-
GPON and WiFi

+ SDH solution based on Fujitsu/Alcatel/Huawei devices in deployment and troubleshoot + Switching and Routing network fundamental and advance + GPON solution with deep knowledge of PLOAM/OMCI, activation procedure. Analysis of Private/Public OMCI + WiFi solution with WiFi Management/Control/Data. WiFi bandsteering, WiFi mesh, and WiFi 6, 6E, 7, ...

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions