Tech & Gaming
The Python Book

The Python Book

The Python Book 4th Edition

In the latest edition of The Python Book, you’ll find plenty of creative projects to help you get to grips with one of the fastest-growing programming languages around. Its powerful functionality works brilliantly with the Raspberry Pi, but you'll also find plenty of tutorials that focus on Python’s effectiveness away from the Pi. You’ll learn how to code with Python from the very beginning with our comprehensive masterclass, then go on to complete tutorials to consolidate your skills and become fluent in the language. Get started with Python - Learn Python the right way with our masterclass. 50 essential Python commands - Discover 50 commands every Python user needs. Work with Python - Improve systems and efficiency using Python. Create with Python - Complete fun projects and improve your programming skills.

United Kingdom
Future Publishing Ltd
Read More

in this issue

11 min.
get started with python

Python is a great programming language for both beginners and experts. It is designed with code readability in mind, making it an excellent choice for beginners who are still getting used to various programming concepts. The language is popular and has plenty of libraries available, allowing programmers to get a lot done with relatively little code. You can make all kinds of applications in Python: you could use the Pygame framework to write simple 2D games, you could use the GTK libraries to create a windowed application, or you could try something a little more ambitious like an app such as creating one using Python’s Bluetooth and Input libraries to capture the input from a USB keyboard and relay the input events to an Android phone. For this guide we’re going to be…

25 min.
50 essential python commands

Python has a massive environment of extra modules that can provide functionality in hundreds of different disciplines. However, every programming language has a core set of functionality that everyone should know in order to get useful work done. Python is no different in this regard. Here, we will look at 50 commands that we consider to be essential to programming in Python. Others may pick a slightly different set, but this list contains the best of the best. We will cover all of the basic commands, from importing extra modules at the beginning of a program to returning values to the calling environment at the end. We will also be looking at some commands that are useful in learning about the current session within Python, like the current list of variables…

8 min.
50 python tips

Basics 01 Running Python scripts On most of the UNIX systems, you can Python scripts from the command line. 02 Running Python programs from Python interpreter The Python interactive interpreter makes it easy to try your first steps in programming and using all Python commands. You just issue each command at the command prompt (>>>), one by one, and the answer is immediate. Python interpreter can be started by issuing the command: In this article, all the code starting at thesymbol is meant to be given at the Python prompt. It is also important to remember that Python takes tabs very seriously – so if you are receiving any error that mentions tabs, correct the tab spacing. 03 Dynamic typing In Java, C++, and other statically typed languages, you must specify the data type of the function return…

9 min.
code a game of rock, paper, scissors

Resources Python 2: www.python.org/download IDLE: www.python.org/idle This tutorial will guide you through making a rock, paper, scissors game in Python. The code applies the lessons from the masterclass – and expands on what was included there – and doesn’t require any extra Python modules to run, like Pygame. Rock, paper, scissors is the perfect game to show off a little more about what exactly Python can do. Human input, comparisons, random selections and a whole host of loops are used in making a working version of the game. It’s also easy enough to adapt and expand as you see fit, adding rules and results, and even making a rudimentary AI if you wish. For this particular tutorial, we also recommend using IDLE. IDLE is a great Python IDE that is easily obtainable in most Linux…

11 min.
program a game of hangman

Resources Python 2: www.python.org/download IDLE: www.python.org/idle One of the best ways to get to know Python is by building lots of simple projects so you can understand a bit more about the programming language. This time round, we’re looking at Hangman, a multi-round game relying on if and while loops and dealing with strings of text in multiple ways. We’ll be using some of the techniques we implemented last time as well, so we can build upon them. Hangman still doesn’t require the Pygame set of modules, but it’s a little more advanced than rock-paper-scissors. We’re playing around with a lot more variables this time. However, we’re still looking at comparisons, random selections and human input, along with splitting up a string, editing a list and even displaying rudimentary graphics. You should continue to use…

12 min.
play poker dice using python

Resources Python 2: www.python.org/download IDLE: www.python.org/idle So you’ve learnt how to program tic-tac-toe and guessed your way to victory at hangman. Now it’s time to head to Las Vegas and play our cards right. Or in this case, virtual dice, and more like Reno as we continue with our Python game tutorials and introduce you to some poker dice. We’re again using some of the lessons we’ve already learnt, including random number generation, list creation and modification, human input, rule setting, scoring and more. But we’ll also be adding some new skills in this tutorial. Namely, we’ll be creating and appending lists with random numbers, and using functions multiple times in one block of code to cut down on bloat. Again, we recommend using IDLE, and we’re using Python 2 to ensure compatibility with a…