• Complain

Magnus Lie Hetland - Beginning Python: From Novice to Professional, 3rd Edition

Here you can read online Magnus Lie Hetland - Beginning Python: From Novice to Professional, 3rd Edition full text of the book (entire story) in english for free. Download pdf and epub, get meaning, cover and reviews about this ebook. year: 2017, publisher: Apress, genre: Computer. Description of the work, (preface) as well as reviews are available. Best literature library LitArk.com created for fans of good reading and offers a wide selection of genres:

Romance novel Science fiction Adventure Detective Science History Home and family Prose Art Politics Computer Non-fiction Religion Business Children Humor

Choose a favorite category and find really read worthwhile books. Enjoy immersion in the world of imagination, feel the emotions of the characters or learn something new for yourself, make an fascinating discovery.

Magnus Lie Hetland Beginning Python: From Novice to Professional, 3rd Edition
  • Book:
    Beginning Python: From Novice to Professional, 3rd Edition
  • Author:
  • Publisher:
    Apress
  • Genre:
  • Year:
    2017
  • Rating:
    4 / 5
  • Favourites:
    Add to favourites
  • Your mark:
    • 80
    • 1
    • 2
    • 3
    • 4
    • 5

Beginning Python: From Novice to Professional, 3rd Edition: summary, description and annotation

We offer to read an annotation, description, summary or preface (depends on what the author of the book "Beginning Python: From Novice to Professional, 3rd Edition" wrote himself). If you haven't found the necessary information about the book — write in the comments, we will try to find it.

Gain a fundamental understanding of Pythons syntax and features with the third edition of Beginning Python, an uptodate introduction and practical reference. Covering a wide array of Pythonrelated programming topics, including addressing language internals, database integration, network programming, and web services, youll be guided by sound development principles. Ten accompanying projects will ensure you can get your hands dirty in no time.Updated to reflect the latest in Python programming paradigms and several of the most crucial features found in latest Python 3. Advanced topics such as extending Python and packaging/distributing Python applications, are also covered.

Magnus Lie Hetland: author's other books


Who wrote Beginning Python: From Novice to Professional, 3rd Edition? Find out the surname, the name of the author of the book and a list of all author's works by series.

Beginning Python: From Novice to Professional, 3rd Edition — read online for free the complete book (whole text) full work

Below is the text of the book, divided by pages. System saving the place of the last page read, allows you to conveniently read the book "Beginning Python: From Novice to Professional, 3rd Edition" online for free, without having to search again every time where you left off. Put a bookmark, and you can go to the page where you finished reading at any time.

Light

Font size:

Reset

Interval:

Bookmark:

Make
Magnus Lie Hetland 2017
Magnus Lie Hetland Beginning Python 10.1007/978-1-4842-0028-5_1
1. Instant Hacking: The Basics
Magnus Lie Hetland 1
(1)
Trondheim, Norway
I ts time to start hacking. In this chapter, you learn how to take control of your computer by speaking a language it understands: Python. Nothing here is particularly difficult, so if you know the basic principles of how your computer works, you should be able to follow the examples and try them out yourself. Ill go through the basics, starting with the excruciatingly simple, but because Python is such a powerful language, youll soon be able to do pretty advanced things.
To begin, you need to install Python, or verify that you already have it installed. If youre running macOS or Linux/UNIX, open a terminal (the Terminal app on a Mac), type in python , and press Enter. You should get a welcome message, ending with the following prompt:
>>>
If you do, you can start entering Python commands immediately. Note, however, that you may have an old version of Python. If the first line starts with Python 2 rather than Python 3 , you might want to install a newer version anyway, as Python 3 introduces several breaking changes.
The details of the installation process will of course vary with your OS and preferred installation mechanism, but the most straightforward approach is to visit www.python.org , where you should find a link to a download page. It is all pretty self-explanatoryjust follow the link to the most recent version for your platform, be it Windows, macOS, Linux/UNIX, or something else. For Windows and Mac, youll download an installer that you can run to actually install Python. For Linux/UNIX, there are source code tarballs that youll need to compile yourself, by following the included instructions. If youre using a package manager such as Homebrew or APT, you can use that to streamline the process.
Once you have Python installed, try to fire up the interactive interpreter. If youre using the command line, you could simply use the python command, or perhaps python3 if you have an older version installed as well. If youd rather use a graphical interface, you can start the IDLE app that comes with the Python installation.
The Interactive Interpreter
When you start up Python, you get a prompt similar to the following:
Python 3.5.0 (default, Dec 5 2015, 15:03:35)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.1.76)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
The exact appearance of the interpreter and its error messages will depend on which version you are using. This might not seem very interesting, but believe me, it is. This is your gateway to hackerdomyour first step in taking control of your computer. In more pragmatic terms, its an interactive Python interpreter. Just to see if its working, try the following:
>>> print("Hello, world!")
When you press the Enter key, the following output appears:
Hello, world!
>>>
If you are familiar with other computer languages, you may be used to terminating every line with a semicolon. There is no need to do so in Python. A line is a line, more or less. You may add a semicolon if you like, but it wont have any effect (unless more code follows on the same line), and it is not a common thing to do.
So what happened here? The >>> thingy is the prompt. You can write something in this space, like print "Hello, world!" . If you press Enter, the Python interpreter prints out the string Hello, world! and you get a new prompt below that.
What if you write something completely different? Try it out:
>>> The Spanish Inquisition
SyntaxError: invalid syntax
>>>
Obviously, the interpreter didnt understand that. (If you are running an interpreter other than IDLE, such as the command-line version for Linux, the error message will be slightly different.) The interpreter also indicates whats wrong: it will emphasize the word Spanish by giving it a red background (or, in the command-line version, by using a caret, ^ ).
If you feel like it, play around with the interpreter some more. For some guidance, try entering the command help() at the prompt and pressing Enter . You can press F1 for help about IDLE. Otherwise, lets press on. After all, the interpreter isnt much fun when you dont know what to tell it.
Algo... What?
Before we start programming in earnest, Ill try to give you an idea of what computer programming is. Simply put, its telling a computer what to do. Computers can do a lot of things, but they arent very good at thinking for themselves. They really need to be spoon-fed the details. You need to feed the computer an algorithm in some language it understands. Algorithm is just a fancy word for a procedure or recipea detailed description of how to do something. Consider the following:
SPAM with SPAM, SPAM, Eggs, and SPAM: First, take some SPAM.
Then add some SPAM, SPAM, and eggs.
If a particularly spicy SPAM is desired, add some SPAM.
Cook until done -- Check every 10 minutes.
Not the fanciest of recipes, but its structure can be quite illuminating. It consists of a series of instructions to be followed in order. Some of the instructions may be done directly (take some SPAM), while some require some deliberation (If a particularly spicy SPAM is desired), and others must be repeated several times (Check every 10 minutes.)
Recipes and algorithms consist of ingredients (objects, things) and instructions (statements). In this example, SPAM and eggs are the ingredients, while the instructions consist of adding SPAM, cooking for a given length of time, and so on. Lets start with some reasonably simple Python ingredients and see what you can do with them.
Numbers and Expressions
The interactive Python interpreter can be used as a powerful calculator. Try the following:
>>> 2 + 2
This should give you the answer 4. That wasnt too hard. Well, what about this:
>>> 53672 + 235253
288925
Still not impressed? Admittedly, this is pretty standard stuff. (Ill assume that youve used a calculator enough to know the difference between 1 + 2 * 3 and (1 + 2) * 3 .) All the usual arithmetic operators work as expected. Division produces decimal numbers, called floats (or floating-point numbers ).
>>> 1 / 2
0.5
>>> 1 / 1
1.0
If youd rather discard the fractional part and do integer division, you can use a double slash.
>>> 1 // 2
>>> 1 // 1
>>> 5.0 // 2.4
2.0
In older versions of Python , ordinary division on integers used to work like this double slash. If youre using Python 2. x , you can get proper division by adding the following statement to the beginning of your program (writing full programs is described later) or simply executing it in the interactive interpreter:
>>> from __future__ import division
Note
In case its not entirely clear, the future in the instruction is surrounded by two underscores on both sides: __future__ .
Another alternative, if youre running an old Python from the command line, is to supply the command-line switch -Qnew . There is a more thorough explanation of the __future__ stuff in the section Back to the __future__ later in this chapter.
Next page
Light

Font size:

Reset

Interval:

Bookmark:

Make

Similar books «Beginning Python: From Novice to Professional, 3rd Edition»

Look at similar books to Beginning Python: From Novice to Professional, 3rd Edition. We have selected literature similar in name and meaning in the hope of providing readers with more options to find new, interesting, not yet read works.


Reviews about «Beginning Python: From Novice to Professional, 3rd Edition»

Discussion, reviews of the book Beginning Python: From Novice to Professional, 3rd Edition and just readers' own opinions. Leave your comments, write what you think about the work, its meaning or the main characters. Specify what exactly you liked and what you didn't like, and why you think so.