Python for Beginners
eBook - ePub

Python for Beginners

Learn the Fundamentals of Computer Programming

J Foster

Buch teilen
  1. English
  2. ePUB (handyfreundlich)
  3. Über iOS und Android verfügbar
eBook - ePub

Python for Beginners

Learn the Fundamentals of Computer Programming

J Foster

Angaben zum Buch
Buchvorschau
Inhaltsverzeichnis
Quellenangaben

Über dieses Buch

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.

Häufig gestellte Fragen

Wie kann ich mein Abo kündigen?
Gehe einfach zum Kontobereich in den Einstellungen und klicke auf „Abo kündigen“ – ganz einfach. Nachdem du gekündigt hast, bleibt deine Mitgliedschaft für den verbleibenden Abozeitraum, den du bereits bezahlt hast, aktiv. Mehr Informationen hier.
(Wie) Kann ich Bücher herunterladen?
Derzeit stehen all unsere auf Mobilgeräte reagierenden ePub-Bücher zum Download über die App zur Verfügung. Die meisten unserer PDFs stehen ebenfalls zum Download bereit; wir arbeiten daran, auch die übrigen PDFs zum Download anzubieten, bei denen dies aktuell noch nicht möglich ist. Weitere Informationen hier.
Welcher Unterschied besteht bei den Preisen zwischen den Aboplänen?
Mit beiden Aboplänen erhältst du vollen Zugang zur Bibliothek und allen Funktionen von Perlego. Die einzigen Unterschiede bestehen im Preis und dem Abozeitraum: Mit dem Jahresabo sparst du auf 12 Monate gerechnet im Vergleich zum Monatsabo rund 30 %.
Was ist Perlego?
Wir sind ein Online-Abodienst für Lehrbücher, bei dem du für weniger als den Preis eines einzelnen Buches pro Monat Zugang zu einer ganzen Online-Bibliothek erhältst. Mit über 1 Million Büchern zu über 1.000 verschiedenen Themen haben wir bestimmt alles, was du brauchst! Weitere Informationen hier.
Unterstützt Perlego Text-zu-Sprache?
Achte auf das Symbol zum Vorlesen in deinem nächsten Buch, um zu sehen, ob du es dir auch anhören kannst. Bei diesem Tool wird dir Text laut vorgelesen, wobei der Text beim Vorlesen auch grafisch hervorgehoben wird. Du kannst das Vorlesen jederzeit anhalten, beschleunigen und verlangsamen. Weitere Informationen hier.
Ist Python for Beginners als Online-PDF/ePub verfügbar?
Ja, du hast Zugang zu Python for Beginners von J Foster im PDF- und/oder ePub-Format sowie zu anderen beliebten Büchern aus Informatique & Programmation en Python. Aus unserem Katalog stehen dir über 1 Million Bücher zur Verfügung.

Information

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

Inhaltsverzeichnis