Python tutorials #1 – basic calculator

This is the first of my Python tutorials! Python is a programming language but unlike C++ and Java, is easier to learn but can still be used to create amazing programs such as web browsers, calculators, word processors, and more. But unlike Scratch, a GUI used to make games and other projects aimed at beginners and young children, you still must master Python to create amazing applications using it.

So, here’s my first tutorial: a basic calculator that can be used to add, subtract, multiply, and divide two numbers. Unlike the calculator app preloaded on your PC or phone however, it is CLI based so you won’t have a friendly GUI calculator but rather one where you type two numbers, what you want to do with them, then get the result printed to the screen.

This guide assumes that you are using the newer Python 3.x. The code may work on Python 2.x, but has not been tested, so if you need to stick to Python 2.x for some reason, you may have to make adaptations to the code for it to work properly.

Fire up your Python IDE (such as IDLE3 or Geany) and enter in the following code:

first_number = input("Enter in first number: ")
second_number = input("Enter in second number: ")
print(int(first_number) + int(second_number))

This basic block of code will ask you to enter in the first number, then store that first number, then enter the second number, store that second number, and then show the answer. The int around the variables converts them into intergers so they can be added together as numbers, not as characters. Without this 5 + 10 would equal 510, not 15.

This, however, is a little restricted. You can only add the two numbers, not subtract, multiply, or divide. Asking the user for what they want to do with the two numbers and then doing that expands the calculator’s functionality. For example:

first_number = input("Enter in first number: ")
second_number = input("Enter in second number: ")
option_choice = input("Add, subtract, multiply, or divide? ")
if 'dd' in option_choice:
print(int(first_number) + int(second_number))
elif 'ubtract' in option_choice:
print(int(first_number) - int(second_number))
elif 'ultiply' in option_choice:
print(int(first_number) * int(second_number))
elif 'ivide' in option_choice:
print(int(first_number) / int(second_number))

We are not doing if statements to see if, for example, option_choice equals ‘add’ as Python is case sensitive in this area. Checking for ‘dd’ (end of ‘add’) ensures that the program will work regardless of whether A is capital or not.

So there you have it! A basic calculator made in Python. Currently lacks support for decimals however, so if you try entering decimals the program will error out. This guide is aimed at beginners, so this calculator will likely be expanded on in a future guide. Enjoy!

-Chas 😎

One lovely blog award – who are my favourite bloggers?

This challenge has spread across the internet like fire (I didn’t create this challenge) so I have decided to do one. Basically, I have to tell you 7 things about my character. And up to 15 bloggers I enjoy. I have over 40 followers, but as there are limits (a few don’t have blogs) and you can only do up to 15. I am sorry if I do not include you!

So, here are the 7 things about me!

1. I think about my web browser project, ECG SeaSurf , for a lot of my time. I love it because the world wide web is a big place, and making software that allows people to browse such a great thing makes me feel special.

2. I do not try to block the spotlight from other developers as I love seeing what others have produced too, and I love getting inspired.

3. I love playing video games because they are extremely fun, and it feels like I am in the game (no VR here!). They also take stress away.

4. I love writing stories, to entertain people. I am writing a story called Sir Wolf’s Castle, about Minecraft wolves and a villan called Sir Bum-Smacker.

5. I love looking at over blogs and leaving feedback and liking posts because I don’t want to look selfish.

6. I love ketchup. It is an awesome sauce.

7. There are lots of other things I love but don’t blog about: Star Wars and Legends of Chima, for example.


1. Codeinfig:

An author of a coding language called Fig, a coding enthusiast, and much more. Check out his blog at!

2. Jacque:

If you want to go beyond my app-making service (I would recommend trying it first and requesting a removal if you don’t like it), then Jacque is the person for you. He can even get your app published to the Play Store (I didn’t ask for an app because I can make one myself).

Check out his blog at

3.  ARJ

If you want a guide to coding and you want to be a pro, then ARJ’s blog “A bit of everything – copy” is the place for you. He has another blog,, which is worth checking out too.

Find his main blog at

4. Daniel He hetianding

A Minecraft enthusiast, this blogger creates maps and then publishes them.

Find his blog at

5. LZH

A real tech enthusiast, admin of a website called TechCentral which contains everything tech.

Leave a comment or like at

6. AntonioWestley

A master blogger, who loves posting about sites he recommends.

Check out his active site at

Check out his inactive site at

7. antepher

A real ESP8266 and Arduino enthusiast, as well as Python Expert, antepher maintains a blog called techtutorialsx.

Like and comment on his blog at!

8. Paul Sinha

One of my first followers, Paul Sinha appears on the Chase and is really funny.

Check out his blog at

9. Old and New Reviews

Reviewing and playing video games, I enjoy reading this blog.

Follow the blog at!

10. Is there any blog you recommend?

I can’t think of a tenth, but I want to reach 10, so if you recommend a blog, plz leave  a comment.

PS: The rules (I have forgotten the URL to the original creator’s blog) also mention that you should post about being chosen. So, thank you codeinfig for choosing me! SO, remember that!

Epic Chas Gamer 😀




Python, GTK and WebKit – creating a web browser – Part 2


In Part 1, I showed you how to create a very basic web browser in Python with WebKit and GTK. It is a great example of Python’s power, but there was no refresh button. Part 2 focuses on adding this feature so you can refresh unresponsive pages.

First, load up the Python script you created in Part 1 and find the lines:

self.address_bar = gtk.Entry()
self.gobutton = gtk.Button(“GO!”)

And put the following above self.address_bar = gtk.Entry()

self.refresh = gtk.ToolButton(gtk.STOCK_REFRESH)

Then find the

self.address_bar.connect(‘activate’, self.load_page)
self.gobutton.connect(‘clicked’, self.load_page)

…and put the following above self.address_bar.connect(‘activate’, self.load_page):

self.refresh.connect(‘clicked’, self.refresh_page)

Eh, what is going on here! The variable self.refresh_page doesn’t even exist. Well, it doesn’t yet. We will later add that variable so you can run this program without errors.

Now, find the lines:

self.navigation.pack_start(self.gobutton, False)

And add the following above self.navigation.pack_start(self.address_bar):

self.navigation.pack_start(self.refresh, False)

Now find:  def change_url(self, widget, frame):
uri = frame.get_uri()
self.address_bar.set_text(uri) and press enter beneath it. If you are using a Python IDE, then press enter twice then backspace once.

Now add the following lines:

def refresh_page(self, widget):

Now we have finished Part 2 of your basic browser. I am thinking of what to show you in Part 3 currently, but I am sure it will be awesome!

The finished code:


#!/usr/bin/env python
import gtk, webkit, os, pickle

class Basic():

def __init__(self):
self.window = gtk.Window()
self.window.connect(‘destroy’, lambda w: gtk.main_quit())
self.window.set_default_size(640, 480)

self.navigation = gtk.HBox()
self.refresh = gtk.ToolButton(gtk.STOCK_REFRESH)
self.address_bar = gtk.Entry()
self.gobutton = gtk.Button(“GO!”)

self.view = gtk.ScrolledWindow()
self.webview = webkit.WebView()‘’)
self.webview.connect(‘title-changed’, self.change_title)
self.webview.connect(‘load-committed’, self.change_url)

self.refresh.connect(‘clicked’, self.refresh_page)
self.address_bar.connect(‘activate’, self.load_page)
self.gobutton.connect(‘clicked’, self.load_page)
self.navigation.pack_start(self.refresh, False)
self.navigation.pack_start(self.gobutton, False)

self.container = gtk.VBox()
self.container.pack_start(self.navigation, False)


def load_page(self, widget):
add = self.address_bar.get_text()
if add.startswith(‘http://’) or add.startswith(‘https://’) or add.startswith(‘file:///’):
add = ‘http://’ + add

def change_title(self, widget, frame, title):
self.window.set_title(title + ” – Basic Web Browser”)

def change_url(self, widget, frame):
uri = frame.get_uri()

def refresh_page(self, widget):
browser = Basic()


Here is what our browser looks like now 🙂


Hope you like it!


Epic Chas Gamer 😀







A new web browser

Python lets you do lots of things, from Calculator programs to Video Games. But there is one capability that you probably don’t know you can do with Python: make a simple web browser.




So, no set release date yet, as I am still working on it. But when I have finished developing it, I may provide a download for you guys to download it!


Epic Chas Gamer 😀

Unofficial Raspberry Pi Clock Application

Hi guys. Today I have been experimenting with Python and Pygame. I managed to make a clock application for the Raspberry Pi.

Here is the code:

import pygame, sys, time


screen = pygame.display.set_mode((1184, 624),
pygame.display.set_caption(“Raspberry Pi Clock”)

clockFont = pygame.font.Font(None, 72)
clock = pygame.time.Clock()


WHITE = (255, 255, 255)
RED = (255, 0, 0)

logo = pygame.image.load(“/usr/share/raspberrypi-artwork/launch.png”)
piclock = pygame.image.load(“raspitimebackground.png”)

screen.blit(piclock, (0, 0))


screen.blit(logo, (0, 0))

theFont = pygame.font.Font(None, 32)
theSurf = theFont.render(“Raspberry Pi”, True, WHITE)
theRect = theSurf.get_rect()
theRect.midtop = (115, 5)
screen.blit(theSurf, theRect)

loadFont = pygame.font.Font(None, 32)
loadSurf = theFont.render(“Press Enter to load the desktop”, True, WHITE)
loadRect = theSurf.get_rect()
loadRect.midtop = (500, 300)
screen.blit(loadSurf, loadRect)
while True:
clockTime = time.strftime(“%H:%M:%S”, time.localtime())
clockText = clockFont.render(str(clockTime), True, WHITE, RED)
screen.blit(clockText, (1000, 550))
for event in pygame.event.get():
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_RETURN:

The following image is required for this project file


If for some reason you ever need this image, feel free to use it. Learn more.

In the future, I will make a blog post about auto starting apps on the Pi.


Epic Chas Gamer 😀


MCPE Multiplayer with Minecraft Pi Edition

The Pi Edition is based on an old version of MCPE, isn’t it. Can you play multiplayer between the two?

If you download a 0.6.1 APK you can play multiplayer by opening a world on the Pi Edition and pressing Join Game on the Pocket Edition. Amazing!




Programming on the Raspberry Pi – Program in python

How to create a window in Python 2.7:

  1. Open Python 2.7 (Idle) from the programming menu and type in the following:

import pygame


screen = pygame.display.set_mode([640, 480])

pygame.display.set_caption(“Hello Python World!”)

NOTE: You can change the title to whatever you want the window to be called.

Save and press F5 on the keyboard.

Our Window:



Epic Chas Gamer 🙂



PS: for a full screen windows then do the line pygame.display.set_mode([640, 480], a comma and then enter, then pygame.FULLSCREEN).