Python basics.

Coding – basic or not?

Lots of coding functions are basic to me: what about you?

In Python 2, you can make a program that prints “Hello, World!” onto the screen:

print “Hello, World!”

In Python 3, you can do this as well:

print(“Hello, World!”)

In Python2 and Python3, you can make an empty window: (you will need Pygame from pygame.org or if using Linux, from your distribution’s repositories, for example it is installable on Debian with sudo apt-get install python-pygame. Same with Ubuntu)

import pygame

window = pygame.display.set_mode((640, 480))
pygame.display.set_caption(“Hello Basic Window!”)
Of course, ignore the Python3 bit if using Python2.

If you have the Epic Chas Gamer blog icon png downloaded onto your PC, you could load it into the program with the following:

ecgicon = pygame.image.load(“epicchasgamer.png”)

Then, you could place it in the window with the following:

window.blit(ecgicon, (0, 0))
pygame.display.flip()

The code altogether would be:

import pygame

window = pygame.display.set_mode((640, 480))
pygame.display.set_caption(“Hello Basic Window!”)

ecgicon = pygame.image.load(“epicchasgamer.png”)

window.blit(ecgicon, (0, 0))
pygame.display.flip()

Have fun!

Epic Chas Gamer 🙂

PS: This document only introduces the basics of Python. There is lots more you can do with the coding language.

PPS: You see that like button? Smash it to pieces!

Go on, you know you want to! Leave a comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: