0% found this document useful (0 votes)
5 views16 pages

Getting Started With Python

Chapter 5 introduces Python as an easy-to-learn, powerful object-oriented programming language developed by Guido Van Rossum. It highlights Python's features such as code readability, cross-platform compatibility, and its various applications, while also noting its limitations like slower execution speed and fewer libraries compared to other languages. The chapter also covers working in both interactive and script modes using Python IDLE and Spyder IDE, including a simple 'Hello World' program example.

Uploaded by

bojocol533
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views16 pages

Getting Started With Python

Chapter 5 introduces Python as an easy-to-learn, powerful object-oriented programming language developed by Guido Van Rossum. It highlights Python's features such as code readability, cross-platform compatibility, and its various applications, while also noting its limitations like slower execution speed and fewer libraries compared to other languages. The chapter also covers working in both interactive and script modes using Python IDLE and Spyder IDE, including a simple 'Hello World' program example.

Uploaded by

bojocol533
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Chapter 5

Getting started with Python


Python is an easy to learn yet powerful object oriented
programming language. It is very high level programming
language yet as powerful as many other programming
languages like C, C++, Java etc.
Python programming language was developed by Guido
Van Rossum in February 1991 and further developed by
the Python Software Foundation. It was designed with an
emphasis on code readability, and its syntax allows
programmers to express their concepts in fewer lines of
code.
It is based on two programming languages :
ABC language, created as a replacement of BASIC and
Modula-3
Python is named after the comedy television show Monty
Python’s Flying Circus. It is not named after the Python
snake.
There are two major Python versions: Python 2 and
Python 3. Both are quite different.
Free and Open Source : It is freely available without any
cost. It is open source means its source-code is also
available which you can modify, improve .
Easy to use : It is compact and very easy to use OOP
language with very simple syntax rules.
Expressive Language : It is more capable to expressing
the code’s purpose than many other languages.
Ex. //In C++ Swapping values #In Python: Swap values
int x=2,y=3,temp; x,y=2,3
temp=x; x,y=y,x
x=y;
y=temp
Interpreted Language : It interprets and executes the
code line by line at a time.
Complete Language: All types of required functionality is
available through various modules of Python standard
library.
Cross-platform Language: It can run on variety of
platforms like Windows, Linux/UNIX, Macintosh,
Supercomputers, Smart phones etc. It is a portable
language.
Variety of Applications: Python is being used in many
diverse fields/applications like :
Scripting
Web Applications
Game developments

Systsem Administrations
Rapid Prototyping
GUI Programs
Database Applications
Not the Fastest Language : It is not a fully compiled
language. So, execution tend be slower. It is first semi-
compiled into an internal byte-code which is then
executed by a Python Interpreter.
Lesser Libraries than C,Java, Perl
Not Strong on Type-binding : It is not very strong on
catching “Type mismatch” issues.
Not Easily Convertible : Because of its lack of syntax, it is
difficult to translate a Python program into another
programming language program which has strong
syntax.
There are various Python distributions available
today:

Default installation available from [Link] is


called CPython installation.
Anaconda Python distribution is highly recommended
distribution that comes preloaded with many packages
and libraries e.g. NumPy, SciPy, Panda etc.
Many popular IDEs are also available e.g. Spyder IDE,
PyScripter IDE etc. Of these, Spyder IDE is already
available as a part of Anaconda Python distribution.
Working in Interactive Mode(Python IDLE)
In interactive mode, you type one command at a time and
the Python executes the given command there and then
and gives the output.
To work in interactive mode, follow the following steps:
i) Click Start buttonAll ProgramsPython 3.8IDLE
Or
Click Start buttonAll ProgramsPython 3.8Python 3.8
ii) It will open Python shell with Python prompt >>>

iii) Type command in front of Python prompt


Working in Script Mode(Python IDLE)
In Script mode you can save all the commands in the form
of program file and show all the output lines together
which is not possible in Interactive mode.
To work in interactive mode, follow the following steps:
Step 1 : Click Start buttonAll ProgramsPython 3.8IDLE
Step 2 : FileNew
Step 3 : In the new window, type the commands to save in the form of
a program.
Step 4 : Click FileSave and save the file with an extension .py

Step 5 : RunRun Module or Press F5 key


Anaconda distribution provides the following tools that you
can use to work in Python.
Jupyter notebook: It is a web based, interactive
computing environment.
Spyder : It is a powerful Python IDE with many useful
editing, interactive testing and debugging features
Working in Spyder IDE
To launch Spyder IDE:
Start buttonProgramsAnacondaSpyder
Interactive Mode

To work in interactive mode in Spyder IDE, type the


command in the Ipython console pane of spyder window.
It will give the output of the command therer itself.
Script Mode
To work in script mode in Spyder IDE, type commands in
the editor pane.
To save current script, use command
FileSave or FileSave As
Make sure to select file type as Python Files

Click on the Run icon on the toolbar or Click RunRun


or Press F5 key
My First Program-Hello World
1. Start Spyder IDE
2. Click FileNew File and type the following text in the editor window.
#My First Program
print(“Hello World”)

3. Save as type as Python Files and give .py extension.


[Link] your script : Click on Run icon [▶] or by clicking RunRun
command or pressing F5 key.
5. It will show the output in the console window

Understanding print()
To print or display output, Python provides print function.
Syntax: print([“prompt”],[variable1/Expr1],[variable2/Expr2],……..)
E.g. print(“Hello World”)
print(“Percentage=“,percent)
The Hello World Program
References: 1)Computer Science with Python By Sumita Arora

You might also like