Python Tutorial

Introduction: Python Tutorial

Hello! Welcome to my second instructable and this will be on the basics of python.

In this instructable, I will be teaching u the basics of loops, input and output, getting the computer to say something, if statements and variables. In the last one we will be using GUIs or graphic user interface with a tool called easygui.

Again, leave comments on how I should improve and questions on bits u don't understand

have fun!


In this step, we will be learning how to make python say something. very simple. all u have to type is what u want to say, then put this around it. print (''). for example print ('hello world'). if u are using python 2 u would type print "hello world" type this into the shell window - the one that comes up and press enter.

there u go! ur first program

Step 2: This Is a Bit Loopy....

now firstly, press Ctrl+N that will get u to a new file. save it as the .py bit indicates that this is a python file. this is the first type of loop.

for i in range (1, 101):

print (i)

this will go like this












the variable, i , will automatically add one each time it loops mind though, it does not print 101.

here is another loop


while i<100:


print (i)

this is very similar to the top one. we call the top one a for loop and the bottom one a while loop.

the while loop includes the 100 so no need to do while i<101.

Step 3: Input and Output

this program will make the computer ask u something and respond to the answer.

this is an example

f=input('what's ur name')<-----------sets the variable and indicates an input

print ('hello',f)<-------------------------prints the variable which is inputted by the user with hello in front

the output should be something like this:

>>>what's ur nameLarry

>>>hello Larry

as u can see the input isn't very neat. if u want a space, space the end of the first line:

f=input('what's ur name ')

if u want it to ask for ur age or how many mars bars u have, do this:

f=int(input('what's ur age'))

if its a decimal number, do:

f=float(input('enter a decimal number'))

how're u hangin' on?

Step 4: If by Rudya-----no No No! It's Python U Dimwit!

if statements are usually used to compare 2 strings or integers.

it usually comes after an input

type the program in the picture and u will be able to see how useful if can be and something u wont expect...

always type:

if *something*<,>,=,!=,<=,>=*something else*:

print (*something*'is whatever than'*something else*)

Step 5: Starter on Easygui

easygui is a module that needs to be downloaded.

download it if u don't have it then try this program.

import easygui

easygui.msgbox('hello world')

it should come up with something like in the picture.

Step 6: What Next?

so that's it for now.

keep an eye open, i might do other tutorials like windows batch and other languages. bye!

really well done that is a lot to learn!

apart from the instructables ive written, there are a load of other tutorials on various languages. if you want to get a pdf with more content, i highly recommend Hello World Book2 which is available on the internet - just search it up.

if you havent managed to install easygui and would like to, download this link:

i've also created my own module called PyCal which let's you calculate things with a difficult formula like Pythagoras' theorem and the area of a circle.

Be the First to Share


    • Backyard Contest

      Backyard Contest
    • On a Budget Challenge

      On a Budget Challenge
    • Teach With Tinkercad Contest

      Teach With Tinkercad Contest


    kinglarry II
    kinglarry II

    3 years ago

    try to do a program which converts farenheit to celcius asking for user input. the conversion formula is c= 5/9*(f-32)

    kinglarry II
    kinglarry II

    Reply 3 years ago

    was it helpful?

    DIY Hacks and How Tos
    DIY Hacks and How Tos

    Reply 3 years ago

    Python is something that I have been meaning to get into but I just can't find the time. But when I do I will definitely come back and give it another look.

    kinglarry II
    kinglarry II

    Tip 3 years ago on Step 5

    part of the easygui installation process requires u to move the file (aka to wherever python can find it presumably in some file called program files (x84). u can always run the program and learn the other bits and bobs of the module. lot to learn. to use it they all begin with this:

    easygui.*whatever*box ('')

    oh by the way, if the picture has been badly edited, click on it to view everything

    kinglarry II
    kinglarry II

    Tip 3 years ago on Step 4

    if ur using python 2.x.x u can also do '<>' instead of '!='