Python for Beginners
eBook - ePub

Python for Beginners

Learn the Fundamentals of Computer Programming

J Foster

Partager le livre
  1. English
  2. ePUB (adapté aux mobiles)
  3. Disponible sur iOS et Android
eBook - ePub

Python for Beginners

Learn the Fundamentals of Computer Programming

J Foster

DĂ©tails du livre
Aperçu du livre
Table des matiĂšres
Citations

À propos de ce livre

With so much information about programming and online coding tutorials out there, it can be difficult to know where to start. Python for Beginners fills in the gap and provides a great place to start learning computer programming with Python. Using our bestselling, straightforward, step-by-step, visual approach, you'll learn to:

Download and install the python interpreter

Setup your development environment

Get started with python code and syntax

Use variables

Use data types such as integers, strings, lists, tuples, sets, and dictionaries

Use different operators for arithmetic, assignment and Boolean operations

Use selection statements such as if and elif

Use iteration statements such as for and while loops

How to read from and write to files

Create your own functions

Handle program exceptions

Create simple graphic user interfaces using Python tkinter module

Create simple games using the PyGame module.

Techniques are illustrated step-by-step using screen prints, example code, and video demos, together with concise, easy to follow text from an established expert in the field. If you want to learn to code quickly and easily with Python, this is the guide you need.

Foire aux questions

Comment puis-je résilier mon abonnement ?
Il vous suffit de vous rendre dans la section compte dans paramĂštres et de cliquer sur « RĂ©silier l’abonnement ». C’est aussi simple que cela ! Une fois que vous aurez rĂ©siliĂ© votre abonnement, il restera actif pour le reste de la pĂ©riode pour laquelle vous avez payĂ©. DĂ©couvrez-en plus ici.
Puis-je / comment puis-je télécharger des livres ?
Pour le moment, tous nos livres en format ePub adaptĂ©s aux mobiles peuvent ĂȘtre tĂ©lĂ©chargĂ©s via l’application. La plupart de nos PDF sont Ă©galement disponibles en tĂ©lĂ©chargement et les autres seront tĂ©lĂ©chargeables trĂšs prochainement. DĂ©couvrez-en plus ici.
Quelle est la différence entre les formules tarifaires ?
Les deux abonnements vous donnent un accĂšs complet Ă  la bibliothĂšque et Ă  toutes les fonctionnalitĂ©s de Perlego. Les seules diffĂ©rences sont les tarifs ainsi que la pĂ©riode d’abonnement : avec l’abonnement annuel, vous Ă©conomiserez environ 30 % par rapport Ă  12 mois d’abonnement mensuel.
Qu’est-ce que Perlego ?
Nous sommes un service d’abonnement Ă  des ouvrages universitaires en ligne, oĂč vous pouvez accĂ©der Ă  toute une bibliothĂšque pour un prix infĂ©rieur Ă  celui d’un seul livre par mois. Avec plus d’un million de livres sur plus de 1 000 sujets, nous avons ce qu’il vous faut ! DĂ©couvrez-en plus ici.
Prenez-vous en charge la synthÚse vocale ?
Recherchez le symbole Écouter sur votre prochain livre pour voir si vous pouvez l’écouter. L’outil Écouter lit le texte Ă  haute voix pour vous, en surlignant le passage qui est en cours de lecture. Vous pouvez le mettre sur pause, l’accĂ©lĂ©rer ou le ralentir. DĂ©couvrez-en plus ici.
Est-ce que Python for Beginners est un PDF/ePUB en ligne ?
Oui, vous pouvez accĂ©der Ă  Python for Beginners par J Foster en format PDF et/ou ePUB ainsi qu’à d’autres livres populaires dans Informatique et Programmation en Python. Nous disposons de plus d’un million d’ouvrages Ă  dĂ©couvrir dans notre catalogue.

Informations

Éditeur
Elluminet Press
Année
2020
ISBN
9781913151171

Building an Interface

Modern computer applications are built with graphic user interfaces in mind. The user interacts with the application using windows, icons, menus and a mouse pointer rather than console-based I/O.
To create a graphic user interface using Python you’ll need use Tkinter (Tk interface). This module is bundled with standard distributions of Python for all platforms.
For this section, take a look at the video demos
www.elluminetpress.com/pygraphics
You’ll also need the source files in the directory Chapter09.

Creating a Window

The first thing you need to do is import the tkinter module into your program. To do this, use
from tkinter import *
To create a window use the Tk() method
window = Tk()
Add a title
window.title(‘Window Title’)
Set the initial size and position of the window. Use the .geometry() method.
window.geometry(“800x600+50+20”)
The first two numbers in this case ‘800x600’, sets the window size. Set this to the desired window size in pixels. This could be 1280x720, 1920x1080, and so on.
The second two numbers in this case ‘50+20’, sets the initial position of the window on the screen using x and y co-ordinates
Lets take a look at a program. Open window.py. Here, we’ve created a window. You can do this using the Tk() function and assign it to a window object.
We’ve sized the window so that is 640 pixels wide by 480 pixels high. We’ve also positioned the window 500 pixels across from the top left by 20 pixels down. You can do this using the .geometry() method. This is the initial size and position of the window on screen.
We’ve also added a window title. You can do this using the .title() method. This helps to identify your app.
Finally to make the window appear, we need to enter the Tkinter event loop. You can do this with the .mainloop() method.
window.mainloop()
This is an infinite loop used to run the application and is called an event loop. The .mainloop() method waits for an event such as a key press, or mouse click events from the window system and dispatches them to the application widgets (frames, buttons, menus, etc).
2323__p...

Table des matiĂšres