top of page

पायथन का परिचय

 Introduction to Python

 Python is an open source, easy to understand and versatile language. Some Facts  :

•Developed by Guido van Rossum in the late1980s.

•It is a high level programming language that can be used to create powerful applications.

•It is an interpreted , interactive language

 

Features of Python

1. Open Source

  • Python is open source and free.

  • Source code is easily accessible

  • Python can also be freely modified and re-distributed

2. Portable

  • Python is platform independent

  • It can run on Windows. Mac OS and Linux alike

3. Powerful

  • Supports dynamic data typing

  • Large standard library that supports many common programming tasks

  • Automatic memory management

4. Easy to Use & Learn

  • Its easy to download and install Python

  • Structure and syntax are very simple and easy to understand

5. Compatible with other HLL

  • Can be extended by adding new modules implemented in a compiled language such as C or C++.

  • Can also be embedded into an application to provide a programmable interface

6. Versatile in usage; used for

  • Scripting

  • Web Applications

  • Game development

  • Database Applications

  • GUI programs

  • System Administrations

Python Modes

Python is a versatile language. Programmers can choose to write their programs in Interactive mode or the Script mode.

1. The interactive mode is a feature of Python which provides immediate feedback for every statement you type on the console. The statements are executed line by line. Command line and Shell are the two interactive modes in Python. The interactive mode provides a python interpreter prompt, >>>, where users can start typing.

2. IDLE is the Python IDE(Integrated Development Environment). Apart from the Python Shell , it also provides the Script mode. In the Script mode we write the program , save it and then it is executed as a complete unit.

 

 

 

 

 

 

 

Working with Python

The Python Code : Hello World program

We shall now consider the  most basic program in Python; the "Hello World" program. Let us see how it works in the command line as well as the IDLE mode.

The Python command line can be launched on the desktop using the following steps:

       start---->All programs/apps---->Python 3.6(32 bit)

Once Launched the screen will look like the one below. Note the Python Interpreter prompt: >>>

Now we enter the “Hello World” program  on the python interpreter prompt and press enter. The program consists of one single command, print("Hello World")

 

 

 

 

 

 

Note that we get the output immediately on the next line.

In most other High level languages, we would typically need to type 4-5 lines of code to produce the same output!!

The print command can be used to display various type of data after evaluation, like shown below. We shall discuss the command in detail later on.

 

 

 

 

 

 

 

 

 

To quit the interpreter prompt(command line) we can do any of the following:

•Press ctrl+z or

•Type quit() or exit() at the prompt

 

The Python IDE:Python IDLE

The Python IDLE or integrated development environment  lets the user enter a program in any of the two ways

 

1. By directly typing the Python statements on the Python prompt in the Shell window

 

 

2. By writing programs in a file and then saving them before running using the run module.

Working in Python shell

The Python Shell can be opened using the following steps:

Start----->All programs/apps---->Pyython IDLE 3.6

When we start the Python IDLE, the Python Shell window appears with the interpreter prompt : >>>

The Python shell responds to the statements or commands immediately. 

 

Working with Python Script mode: Writing, saving and running a Python program

To write a program in script mode we need to follow the following steps.

Step 1: Open a New file using the File menu:

 

 

 

Step 2:Now the new file opens which is actually an editor where you can type the “Hello World “ program.

Step 3: Now click on the Run menu, then select Run Module 

 

 

 

 

 

 

 

 

​                                                       ​

Step 4: When you click on the Run menu , you will be prompted to save the program. Click ok to save.

Save the program by clicking ok

 

Step 5: Give a name to your program. For example, here the name given is MyFirstProgram

 

Step 6 :Type the name of  the program file

After saving the program file, it will automatically execute and the output will be shown in the Shell window.

 

​​The output in the Shell Window

 

 

Try Yourself:

Now try typing in some simple print commands in Python and run them using this built in editor. It works just like Python Idle where you can either use the script mode or interactive mode to write the program. Note, we shall be using this editor to write and test programs throughout this tutorial.

modespython.JPG
prompt1.JPG
prompt2.JPG
prompt3.JPG
prompt7.JPG
prompt4.JPG
prompt6.JPG
prompt5.JPG
Python Features
Working with Python
Python Modes
scriptmode1.JPG
scriptmode2.JPG
scriptmode5.JPG
scriptmode3.JPG
scriptmode4.JPG
scriptmode6.JPG
Python IDE
Python Shell
Python Script Mode
Try Yourself
bottom of page