Python for Beginners
eBook - ePub

Python for Beginners

Learn the Fundamentals of Computer Programming

J Foster

Compartir libro
  1. English
  2. ePUB (apto para móviles)
  3. Disponible en iOS y Android
eBook - ePub

Python for Beginners

Learn the Fundamentals of Computer Programming

J Foster

Detalles del libro
Vista previa del libro
Índice
Citas

Información del 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.

Preguntas frecuentes

¿Cómo cancelo mi suscripción?
Simplemente, dirígete a la sección ajustes de la cuenta y haz clic en «Cancelar suscripción». Así de sencillo. Después de cancelar tu suscripción, esta permanecerá activa el tiempo restante que hayas pagado. Obtén más información aquí.
¿Cómo descargo los libros?
Por el momento, todos nuestros libros ePub adaptables a dispositivos móviles se pueden descargar a través de la aplicación. La mayor parte de nuestros PDF también se puede descargar y ya estamos trabajando para que el resto también sea descargable. Obtén más información aquí.
¿En qué se diferencian los planes de precios?
Ambos planes te permiten acceder por completo a la biblioteca y a todas las funciones de Perlego. Las únicas diferencias son el precio y el período de suscripción: con el plan anual ahorrarás en torno a un 30 % en comparación con 12 meses de un plan mensual.
¿Qué es Perlego?
Somos un servicio de suscripción de libros de texto en línea que te permite acceder a toda una biblioteca en línea por menos de lo que cuesta un libro al mes. Con más de un millón de libros sobre más de 1000 categorías, ¡tenemos todo lo que necesitas! Obtén más información aquí.
¿Perlego ofrece la función de texto a voz?
Busca el símbolo de lectura en voz alta en tu próximo libro para ver si puedes escucharlo. La herramienta de lectura en voz alta lee el texto en voz alta por ti, resaltando el texto a medida que se lee. Puedes pausarla, acelerarla y ralentizarla. Obtén más información aquí.
¿Es Python for Beginners un PDF/ePUB en línea?
Sí, puedes acceder a Python for Beginners de J Foster en formato PDF o ePUB, así como a otros libros populares de Informatique y Programmation en Python. Tenemos más de un millón de libros disponibles en nuestro catálogo para que explores.

Información

Año
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...

Índice