Introduction to Python Programming
4 min read
Programming is a way of giving input or telling our computer to perform tasks
so that computer takes our command and search for it and then return the
result.
Everything you provide to computer is converted in to machine code. For
example text, audio, video, images, etc..
We are here to learn about one of the programming language i.e. Python.
Python is a programming language invented by Guido Van Rossum. In 1989 he
started implementing concept of ABC language(it was also a language but have
much more issues with it). He wanted to make most easier and less coding
language.
In February 1991, he released first version of Python with version name 0.9.0.
In this version the features of this programming language were exception
handling, functions, and the core data types like list, set, dict, tuple etc..
Python was named on "Monty Python's Flying Circus". Guido was one the biggest
fan of this circus so he decided to name Python.
Finally he released his second version with tons of features like lambdas,
mapping, reduce and filter, etc.. in January 1994 and named it "Python 1.0".
He release Python's most successful version of that time i.e. "Python 2.0" in
October 2000,which had features like list comprehensions, garbage collector,
and Unicode support, etc..
Finally in December 2008 Guido released "Python 3.0" version or "Python 3000"
or "py3k",with new features like:
- Print is a function now.
- View and iterators instead of lists.
- The rules for ordering comparisons have been simplified.
- There should be only one integer data type i.e. int, long is also added in int.
- Division of two numbers will return a float value instead of an integer.
- Text vs Data instead of Unicode vs 8-bit, and some new syntaxes.
Let me show you the first program of Python to you:-
print("Hello World!")
and that's it you are done will discuss in another blog on how this work till
then you understand the basic of Python.
Features of Python Programming language:-
1. Python is interpreted programming language.
2. It has very simple syntaxes and have extensive library.
3. Readability is very good in Python.
4. Less number of instructions.
5. Easy to execute as well as easy to write programs in Python.
6. Less error prone programming language.
7. Python is static as well as dynamic programming language.
8. Pre-processor is not required in Python.
9. Python is a platform Independent.
10. Python is both procedure oriented as well as object oriented programming
language.
Let's talk about some Language Fundamental things:
To create Python applications we need some constructs by default from Python
programming language called as Language Fundamental.
We have total 4 language fundamentals:
1. Tokens
2. Data Types
3. Type Casting
4. Python Statements
Let's look out all of them in brief:
1. Tokens:- The collection of lexemes in a particular group is called Tokens
and the logical unit in programming is called Lexeme.
Example:-
sum = number1 + number2
Lexemes: sum, =, number1, +, number2
Identifiers: sum, number1, number2
Operators: =, +
Tokens have 4 types, let's see them with description:-
1. Identifiers:
Giving name to the programming elements or variables, functions, classes,
etc.. called as Identifiers.
There are some rules to write them:-
> Identifier should not be start from number.
example:-
21roll_number ---> Incorrect
> It must start from letter or underscore(_) symbol.
example:-
roll_number = 21 -->correct
_rollnumber = 21 -->correct
> Leaving underscore we cannot use any other symbols like +, -, *, %, etc..
example:-
my_age = 21 -->correct
my+age = 21 -->Incorrect
>Identifiers should not allow white spaces in between them
example:-
my name = "CodeWithDevops" -->Incorrect
> Identifiers are case sensitive means capital letters and small letters
will create 2 different Identifiers.
example:-
name = "ABC"
Name = "ABC" -->Both are correct but both are different
You cannot create identifier with keywords.
example:-
if = "Hi" -->Incorrect
Note:- Variable and Identifiers are not same, variable is a memory location
where data is stored, and name of the variable is called as Identifier.
2. Literals:
Literal is a constant assigned to the variable.
example:-
number1 = 10
age = 21
name = "CodeWithDevops"
Literals are also having 2 types:
1. Numeric Literals:
As you can think from name that numeric means related to numbers. This literal
stored int and float values.
example:-
roll_number = 11
pi = 3.142
2. Non Numeric Literals
Non Numeric Literal stores boolean and string values.
example:-
are_you_student = True
name = "CodeWithDevops"
3. Keywords/ Reserved Words
If any predefined word has both word recognition as well as internal
functonality then they are called as Keywords/Reserved Words.
these words are:
'False', 'None', 'True', '__peg_parser__', 'and', 'as', 'assert', 'async',
'await', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except',
'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda',
'nonlocal', 'not', 'or', 'pass', 'raise', 'return', 'try', 'while', 'with',
'yield'
4. Operators:
Operator is a symbol, that perform a particular operation over the provided
operands.
There are many types of operators, but will explain next time but for basic
knowledge let me show you a few of them:
1. Arithmetic Operator:-
It will perform arithmetic functions like adding, subtracting, multiplying,
dividing, etc..
2. Assignment Operator:-
This operator is use to assign values the identifiers.
So this is it for your basic knowledge, will continue in next blog till then
take care.