How to start programming in python

Topics on common programming languages
Post Reply
User avatar
Shehani
Lieutenant
Lieutenant
Posts: 61
Joined: Mon Aug 19, 2013 2:11 pm

How to start programming in python

Post by Shehani » Fri Oct 11, 2013 12:52 pm

What is Python?

Python is an open source general purpose programming language. It is designed in such a way to improve software quality, developer productivity, program portability and component integration. Python gives more importance to its code readability and its syntax allows programmers to program their idea in fewer lines of code than other programming languages like C does. It is used all round the globe for web designing, system programming, user interfaces, product customization, numeric programming etc.


Why Python?

Python language is simple, readable and has a easily maintainable syntax. Object Oriented, functional and modular structures are possible in Python. It has a good collection of precoded interfaces and utilities. Its very flexible and agile language. It is often referred to as general purpose language. Python is also used in system programming, Graphical user interface creation, Internet programming including accessing network protocols HTTP, emails and FTP. Unlike traditional Programming languages python is flexible. The standard libraries in python includes everything from asynchronous processing to zip files. It has dynamic introspection capabilities and advanced features such as meta-classes, duck typing and decorators.


Downloading and Installing PYTHON GUI


- Download Python 3.3.2 Windows x86 MSI Installer
- Install the setup file, following the steps through the setup
- Open the Python(GUI) IDLE after installation
After Opening Python Shell
After Opening Python Shell
1.jpg (25.8 KiB) Viewed 5879 times
Any tutorial for a programming would should start with a “Hello World”. So lets start with the same. In the GUI type the following print statement.

Code: Select all

print("Hello World")
Then press Enter. You can see the output directly in the interpreter as shown below.
Output at the Shell Interpreter – Python
Output at the Shell Interpreter – Python
2.jpg (24.17 KiB) Viewed 5879 times



This is how the interpreter works. To execute a single command this is all that is required. But as you may know as the program becomes lengthy using the interpreter is not practical. So we will write programs having more than one line in a Python File. You can use text editor or python editor for this purpose.

-> Click File >> New
-> It will open a text editor and type the following program there.

Code: Select all

for i in range(0,10):
   print("Hello World")
-> Save It
-> Run >> Run Module
Creating and Running a Python Program
Creating and Running a Python Program
3.jpg (22.15 KiB) Viewed 5879 times
In this example “Hello World” is printed 10 times using a for loop. The value of i will be incremented from 0 to 9. The output will be displayed at the Shell as shown below.
Output of Python Program
Output of Python Program
4.jpg (40.82 KiB) Viewed 5879 times
Note : Python doesn’t require semicolon (;) at the end of a statement. There is no error if you use semicolon. Semicolon can be used when you need to write more than one statement in a line.




Article courtesy of electrosome.com
Post Reply

Return to “.Net & Other Programming”