Getting Started with Python – Notes

Getting Started with Python Programming Language


Topics:


  • Familiarization with the basics of Python programming:
    • Introduction to Python,
    • Features of Python
    • Advantages & Disadvantages
    • Installation of Python
  • Working with Python
  • Execution modes:
    • Interactive mode and
    • Script mode
    • Executing a simple “hello world” program

Introduction

Python is an open-source, object-oriented, high-level programming language developed by Guido Van Rossum in 1990, and released in 1991, at the National Research Institute for Mathematics, Netherlands.

Presently owned by Python Software Foundation (PSF).

Python is influenced by two programming languages:

ABC language, a teaching language created to replace the programming language BASIC.

Modula-3 is a language that preserves the power of a systems programming language

Python is a general-purpose programming language that can be used to build any kind of program that does not require direct access to the computer’s hardware.


Characteristics of Python

  • It supports functional and structured programming methods as well as OOP.
  • It can be used as a scripting language or can be compiled to byte-code for building large applications.
  • It provides very high-level dynamic data types and supports dynamic type checking.
  • It supports automatic garbage collection.
  • It can be easily integrated with C, C++, COM, ActiveX, CORBA, and Java.
  • It can be used to develop a large application with small codes.

Python – Advantages

It has become popular because of its salient features –

  • Easy – loosely typed OOP language with few keywords and simple English like structure, and is easy to learn
  • Takes less time to develop the program, typically 3-5 times shorter than equivalent Java programs. Due to Built-in high-level data types, and dynamic typing.
  • Free and Open Source, High-Level, Portable, and Object-Oriented
  • Extensible & Embeddable
  • Interpreted – Python is interpreted, interactive, and directly executed with pre-compiled code. This means that it is processed at runtime by the interpreter and you need not compile your program before executing it.
  • Large Standard Library and support GUI Programming (using MFC, Tkinter)
  • Python is used for both scientific and non-scientific programming.
  • Python is a case-sensitive programming language.

Python – Disadvantages

It has some minus i.e. disadvantages –

  • Not the fastest Languages – Python is an interpreted language, not a compiled language. It converts python source code into the internal bytecode, which is then executed by the Python interpreter. It makes slower than fully compiled languages.
  • Not strong as Type Binding – Python does not strongly bind with data types i.e. type.
  • Not easy to convert code into other languages – It is not easy to translate a Python program into other programming languages because Python does not have strong syntax.

Installation of Python


Working with Python:

  1. Python Interpreter: Python interpreter must be installed on your computer, to write and execute a Python program. It is also called a Python shell.
  2. >>> : Symbol >>> is called Python prompt.
  3. Python prompt: Python prompt, which indicates that the interpreter is ready to receive instructions. We can type commands or statements on this prompt for execution.
Python Interpreter Shell

Execution Mode

There are two ways to run a program using the Python interpreter:
a) Interactive mode and b) Script mode

(A) Interactive Mode
In the interactive mode, we can type a Python statement on the >>> prompt directly. As soon as we press enter, the interpreter executes the statement and displays the result(s)

Executing code in Interactive mode

Advantages of using interactive mode :

It is convenient for testing a single line code for instant execution.

The disadvantage of using Interactive mode :

In the interactive mode, we cannot save the statements for future use and we have to retype the statements to run them again.

(B) Script Mode
In the script mode, we can write a Python program in a file, save it and then use the interpreter to execute the program from the file.

  • Python program files have a .py extension.
  • Python programs are also known as scripts.
  • Python has a built-in editor called IDLE which can be used
    to create programs / scripts.

Python IDLE :

IDLE: Integrated Development and Learning Environment

To Create a Program

  • First open the IDLE,
  • Click File>New File to create a new file,
  • then write your program on that file and
  • save it with the desired name.
    By default, the Python scripts are saved in the Python installation folder.

To run/execute a program in script mode:

  • Open the program using an IDLE editor
  • In IDLE, go to [Run]->[Run Module] to execute the program
  • The output appears on the shell.
Executing program in Script Mode

Class 11 Computer Science Notes


Class 11 Computer Science NCERT Exercise Solutions


Leave a Comment

You cannot copy content of this page

Scroll to Top