Getting Started with Python

Introduction to Python

An ordered set of instructions to be executed by a computer to carry out a specific task is called a program.

A program written in high level language is known as source code. Translator programs like Compiler and interpreter are used to convert source code into object code.

Python is a high level programming language, it uses interpreter to convert its instruction into machine language. Python is helpful in web development. Many popular web services and applications are built using python.

Features of Python

  1. It is a free and open source high level language.
  2. Python is an interpreted language.
  3. Python programs are easy to understand.
  4. Python is case sensitive language.
  5. Python is portable and platform independent.
  6. Python has a rich library of predefined functions.
  7. Python uses indentation for blocks and nested blocks.

To write and execute a Python program, a python interpreter is required. A python interpreter is also called Python shell.

Execution Modes:

a) Interactive mode – In interactive mode we can type a python statement directly on the prompt. as we press enter key it executes the statement and displays the result.

b) Script mode – In script mode, we can type a program in a file, save it and then use the interpreter to execute it. Python scripts are saved as file where extension of a file name is  “.py”  .

To execute the script, we can type the filename along with the path at the prompt or after saving the file we can click on Run Module in script mode.

Python Keywords

Keywords are the reserved words of the language. Each keyword has a specific meaning and purpose associated with it.

Identifiers

Identifiers are the names used to identify a variable, a function or other entities.

An identifier can start with a letter or an underscore, it can not start with a digit, preferably it should be short and meaningful.

It should not be a keyword, other special characters are not allowed except underscore.

Variables

Variable in Python refers to an object -an item or element stored in memory. In python assignment statement is used to create a variable and assign values to them.

Comments

Comments are used to add a remark , they are not executed. They are added with the purpose of making source code easier to understand. In Python comments start with a # sign. The interpreter ignores the statement starting with # sign.

Python treats every value, every data item as an object. Every object in Python is assigned a unique identity (ID). id() function returns the identity of an object.

Datatypes

 

 

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top