History:
Python was introduced in 1991 by Guido Van Rossum. Python is 30 years old. 1996 1.x, 2000 2.x, 2010 3.x
Why is it booming right now?
- Because of its characteristics
Dynamic Typing
Interpreted (that runs your program in a terminal window)
Python is object oriented programming language
Python code is portable(Platform Independent)
It is easy and simple
It is case sensitive
The main concepts of an object oriented programming language are:
Polymorphism: Using the same name for multiple functions.
Encapsulation: Binding data and functions as one unit.
Inheritance: Using functions of a preceding class.
Abstraction: Hiding data and sharing functions.
Classes: Groups of different data types and the functions to access and manipulate them. It is a user defined prototype of an object.
Objects: Instances of the class, things you can Operate o``
Setting up environment
Python is a cross-platform programming language, which means it runs on all the major operating systems. Most modern computers that have Python installed already.
Checking Your Version of Python
Linux - Open terminal and type python3
OSx -
Installation
Linux -
$ sudo add-apt-repository ppa:fkrull/deadsnakes
$ sudo apt-get update
$ sudo apt-get install python3.8
These commands will install Python 3.8 to your system. The following code will start a terminal session running Python 3.8:
Window
Click on link and follow steps Click meOSx - python is already installed. If not Click here and download and install
Write First “HelloWorld” Python Program
Open text editor and create a new file and write below code and save with .py extension.
print(“Hello World”)Open terminal and go to file save directory and type below command
python fileName.py
Identifiers
It is used to identify a variable, function, class, module or other object.
Identifier starts with a letter A to Z or a to z or an underscore (_) followed by zero or more letters, underscores and digits (0 to 9).
Keyword:
Keywords are reserved words and you cannot use them as identifier names.
There are a total 33 keywords in Python 3.8.2.
Get Keyword list using python program
>>> import keyword
>>> keyword.kwlist #it will print all keyword
>>> a = keyword.kwlist
>>> a.len()
Comment:
Comment is not a part of our programming language.
comment statements are skipped while executing your program.
There are two types of comments.
Single Line Comment (#)
Multiple Line Comment (''' ''')
msg = "hello comments" # a msg containing something
print(msg) #print statement to print contents of a msg