0% found this document useful (0 votes)
14 views

Python Notes

The document provides an introduction to the Python programming language, describing its history, key features, and basic concepts like tokens, keywords, identifiers, and modes of working in Python such as interactive and script modes.

Uploaded by

kartikg320l
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Python Notes

The document provides an introduction to the Python programming language, describing its history, key features, and basic concepts like tokens, keywords, identifiers, and modes of working in Python such as interactive and script modes.

Uploaded by

kartikg320l
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

1

INTRODUCTION TO PYTHON
Introduction
Python was developed by Guido van Rossum (Dutch programmer) at National
Research Institute for Mathematics & Computer Science in 1991.

Python = ABC + Modula-3

Features of Python
➢ Easy to Use: very programmer-friendly language.
➢ Expressive Language: code is easily understandable.
➢ Interpreted Language: executes the code line by line at a time, this makes
debugging easy & thus suitable for beginners.
➢ Cross-platform Language: can run equally on different platforms such as
Windows, Linux, UNIX, Macintosh, etc. Thus, Python is a portable language.
➢ Free & Open Source: Python language is freely available at www.Python.org.
with its source-code. Therefore, it is open source.
➢ Extendable: new features, plug-ins can easily be done in older version
programs.
➢ Large Standard Library: Python has a large & broad library.
➢ GUI Programming: Graphical user interfaces can be developed using Python.
➢ Database Interfaces: can be connected to almost all databases.
➢ Automatic Garbage Collector.

Some drawbacks
➢ Not the fastest language: not fully compiled once, hence took time to execute.
➢ Not strong on type values: declare a variable as integer, but later store string
in it, Python won’t complain.
➢ Not easily convertible to other language programs due to lack of syntax.

Working in Python
In Python, we can work in two different ways:
➢ Interactive mode
➢ Script mode

Interactive mode: In this, instructions are given in front of Python prompt(window),


in Python Shell. Python carries out the instructions & shows results there itself. It
does not save commands & suitable for testing codes.

Script mode: In this, instructions are stored in a file with .py extension & then are
executed. The saved instructions are known as Python script or Python program. It is
useful for creating programs & then run the programs later & get the output.
Shortcut key to run module/program we use F5 key.

2
PYTHON FUNDAMENTALS
Tokens
The smallest individual unit in a program is known as token or lexical unit. Python
has following tokens: keywords, identifiers, literals, operators & punctuators.

Keywords
Keywords are special reserved words which convey a special meaning to the
interpreter. Each keyword has a special meaning & a specific operation At present
we have 35 keywords as on 3.11.1.
List of Keywords used in Python are:
True False None and as with assert
def class continue break yield else finally
elif del except while global for if
from import raise try or return pass
nonlocal in not Is lambda

import keyword
keyword.kwlist

Identifiers
Identifiers are the names given to the fundamental building blocks in a program.
These can be variables, lists, tuples, dictionaries, functions, etc.
There are certain rules defined for naming i.e., Identifiers.
➢ An identifier is a long sequence of alphabets, numbers & underscore (_).
➢ Keywords should not be used as an identifier name.
➢ No special character except underscore (_) can be used as an identifier.
➢ First character of an identifier can be alphabet, underscore (_) but not digit.
➢ Python is case sensitive i.e.; lower-case & upper-case letters are different.
➢ Identifiers are unlimited in length.

Some valid identifiers Some invalid identifiers

Myfile _CHK DATA-REC (contains special character


AMIT DATE_7_123 under than underscore)
FILE123 Break 29clt (starts with a digit)
Z2T0Z _HK3_4 break (keyword)

You might also like