Technology Inside Out!

Index ¦ Archives ¦ Atom ¦ RSS

PYTHON - Getting Started

1624592_800549696627341_1247213667_n


 

Why Python ?


Python is a **high-level programming** language whose syntax is said to be clear and expressive. Python has a large standard library. Python is an easy to understand language we can learn this language in a few days and for making any gaming software we should must have good knowledge of   **GUI development** using that language. GUI development using Python is very easy and understandable as compared to other language like C, C++or Java.

Starting Python


Creating a simple Hello world program

  1. We need a python compiler to compile python programs which can be downloaded from www.python.org

  2. Writing a program in text file or console

**Text File**

print 'hello world'

Compiling and running the program are done using single  command python ‘filename’ screen1

**Console**

screen2

To get exit from command line interface just type the command **exit()** .

Screenshot-5

To get help about some methods related to python or the keywords  we can type help in command line interface .Follow these steps

  1. Type python in command line to start the interpreter of python.

  2. Type help .

  3. To get help about keywords or modules available in python just type ethe word keyword.

Screenshot-5

Screenshot-5

All these keywords will be discussed in the coming tutorials one by one .As we can see there are nearly **31 keywords** available in python 2.6.5.

**Print statement**


Print statement is used to print the data in python.Printing a statement in python is just so simple as we dont need to add any libraries for using print command as which we have to do in other languages.We have seen how to print "hello world", we  can print same "hello world" in different way by writing 2 words in different inverted commas and printing it .To print 2 words at the same time we use comma operator between them.

Screenshot-5

**Variable** are printed by just writing the name of variables and no inbverted commas are required .Variables will be covered in next tutorial ,there we will be showing how to print the variables . 

Comments


Comments are used to document our  code . We write comments in python  by using **symbol \#** and writing any expression ,line,or character in front of the \#.Compiler ignores the words or expression in comment.

There are two types of comments available in python:

Single line comments

\# is used to write the single line comments .

print 'hello world' #will print hello world

**will print hello world** is a comment and will be ignored by the compiler .

Multiple Line comments

To write multiline comments the symbol is """  """ .

print 'hello world' """ this is a 
                          multiline comment """

  Any query related to this tutorial  can be asked .In our next Tutorial we will discuss about variables .

© The Geeky Way. Built using Pelican. Theme by Giulio Fidente on github.

Disclaimer Privacy policy