Python for Beginners
eBook - ePub

Python for Beginners

Learn the Fundamentals of Computer Programming

J Foster

Condividi libro
  1. English
  2. ePUB (disponibile sull'app)
  3. Disponibile su iOS e Android
eBook - ePub

Python for Beginners

Learn the Fundamentals of Computer Programming

J Foster

Dettagli del libro
Anteprima del libro
Indice dei contenuti
Citazioni

Informazioni sul libro

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.

Domande frequenti

Come faccio ad annullare l'abbonamento?
È semplicissimo: basta accedere alla sezione Account nelle Impostazioni e cliccare su "Annulla abbonamento". Dopo la cancellazione, l'abbonamento rimarrà attivo per il periodo rimanente già pagato. Per maggiori informazioni, clicca qui
È possibile scaricare libri? Se sì, come?
Al momento è possibile scaricare tramite l'app tutti i nostri libri ePub mobile-friendly. Anche la maggior parte dei nostri PDF è scaricabile e stiamo lavorando per rendere disponibile quanto prima il download di tutti gli altri file. Per maggiori informazioni, clicca qui
Che differenza c'è tra i piani?
Entrambi i piani ti danno accesso illimitato alla libreria e a tutte le funzionalità di Perlego. Le uniche differenze sono il prezzo e il periodo di abbonamento: con il piano annuale risparmierai circa il 30% rispetto a 12 rate con quello mensile.
Cos'è Perlego?
Perlego è un servizio di abbonamento a testi accademici, che ti permette di accedere a un'intera libreria online a un prezzo inferiore rispetto a quello che pagheresti per acquistare un singolo libro al mese. Con oltre 1 milione di testi suddivisi in più di 1.000 categorie, troverai sicuramente ciò che fa per te! Per maggiori informazioni, clicca qui.
Perlego supporta la sintesi vocale?
Cerca l'icona Sintesi vocale nel prossimo libro che leggerai per verificare se è possibile riprodurre l'audio. Questo strumento permette di leggere il testo a voce alta, evidenziandolo man mano che la lettura procede. Puoi aumentare o diminuire la velocità della sintesi vocale, oppure sospendere la riproduzione. Per maggiori informazioni, clicca qui.
Python for Beginners è disponibile online in formato PDF/ePub?
Sì, puoi accedere a Python for Beginners di J Foster in formato PDF e/o ePub, così come ad altri libri molto apprezzati nelle sezioni relative a Informatique e Programmation en Python. Scopri oltre 1 milione di libri disponibili nel nostro catalogo.

Informazioni

Anno
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...

Indice dei contenuti