
What can be developed using Python ?
Web and Internet Development.
Desktop GUI Applications.
Statistics and Data Analytics.
Software Development.
Database Access.
Network Programming.
Games and 3D Graphics.
Artificial Intelligence >> Machine Learning
Download Python from this link -
www.python.org/downloads/
Sample Code -
>>> print("String abc@123 ")
String abc@123
>>> "Hello World"
'Hello World'
>>> 45
45
>>> print(45)
45
>>> print('45')
45
>>> print("45")
45
>>> 45.67
45.67
>>> print(45 + 56)
101
>>> print("Hello", "How are you?", 56)
Hello How are you? 56
>>>
Sample Code for the Lecture -
>>> # Numbers , Words , Collections
>>> # Strings - Alphanumeric Characters - A-Z, a-z, 0-9 , !@#$%^&
>>> print("Hello@123!")
Hello@123!
>>> # type()
>>> type("Mohan")
<class 'str'>
>>> "hello"
'hello'
>>> # Numbers - Integers, Float, Complex
>>> type(1)
<class 'int'>
>>> type(-456)
<class 'int'>
>>> 45
45
>>> type(3464654363563563)
<class 'int'>
>>> 45.67
45.67
>>> type(45.67)
<class 'float'>
>>> type(-34.56)
<class 'float'>
>>> 1+5j
(1+5j)
>>> type(1+2j)
<class 'complex'>
>>> # Boolean - True and False
>>> type(True)
<class 'bool'>
>>> type(False)
<class 'bool'>
>>> # Collections
>>> # Lists , Tuples, Sets and Dict
>>> type([45, 67, 89])
<class 'list'>
>>> type((45, 67, 89))
<class 'tuple'>
>>> type({45, 67, 89})
<class 'set'>
>>> # Name and Email - String
>>> # Age - 25
>>> # Are you married - True False
>>> # Salary - 1456.78
>>> # [45,56,77,78,99]
Sample Code :
Python 3.6.8 (tags/v3.6.8:3c6b436a57, Dec 24 2018, 00:16:47) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> # Variables
>>> x = 5
>>> type(5)
<class 'int'>
>>> type(x)
<class 'int'>
>>> name = 'Mohan'
>>> print(name)
Mohan
\
>>> name = "Sohan"
>>> name
'Sohan'
>>> condition = True
>>> condition
True
>>> type(condition)
<class 'bool'>
>>> email = "abc@mail.com"
>>> email1 = "avc@gmail.com"
>>> 1email = "acv@mail.com"
SyntaxError: invalid syntax
>>> # You can not start a varible name with numbers
>>> first name = "Mohan"
SyntaxError: invalid syntax
>>> first@name = "Mohan"
SyntaxError: can't assign to operator
>>> first-name = "Mohan"
SyntaxError: can't assign to operator
>>> date_of_birth = "22July1980"
>>> print(date_of_birth)
22July1980
>>> x = 56
>>> y = 67
>>> x + y
123
>>> x = 78
>>> x + y
145
>>> del x
>>> x
Traceback (most recent call last):
File "<pyshell#26>", line 1, in <module>
x
NameError: name 'x' is not defined
>>> name = "Mohan Singh"
>>> len(name)
11
>>> name
'Mohan Singh'
>>> "My name is " + name
'My name is Mohan Singh'
>>>
Sample Code for the lesson
>>> # Assignment Operators
>>> x = 5
>>> name = "John"
>>> y = [45,6,7]
>>> a = 30
>>> b = a
>>> b
30
>>> u = 45
>>> u = v
Traceback (most recent call last):
File "<pyshell#8>", line 1, in <module>
u = v
NameError: name 'v' is not defined
>>> v = u
>>> v
45
>>> # ADD and Assign
>>> x+=56
>>> # x = x + 56
>>> print(x)
61
>>> a- = 5
SyntaxError: invalid syntax
>>> a -= 5
>>> a
25
>>> a *= 10 # a = a*10
>>> a
250
>>> a /= 5 # a = a / 5
>>> a
50.0
>>> type(a)
<class 'float'>
>>> a %= 4
>>> a
2.0
>>>
>>> # 50 / 4 - 4 * 12 = 48 | 2
>>> a = 50 % 4
>>> 2 ** 5
32
>>> a **= 5
>>> a
32
>>> # a = a ** 5
>>> a //= 3
>>> a
10
>>> # a = a // 3
>>>
Sample Code for the lesson
>>> # Equals to "=="
>>> x = 67
\
>>> y = 68
>>> x == y # is x equal to y
False
>>> x + 1 == y
True
>>> if (x + 1 == y):
print("Correct")
Correct
>>> x != y # is x not equal to y
True
>>> name = "John"
>>> name != "John"
False
>>> a = 56
>>> b = 56.1
>>> a > b
False
>>> b > a
True
>>> # Greater than and equal to
>>> a = 56.0
>>> b = 56
>>> a > b
False
>>> a == b
True
>>> 23 == "23"
False
>>> 23 == int("23")
True
>>> str(23) == "23"
True
>>> a >= b
True
>>> # Less than <
>>> a < b
False
>>> a <= b
True
>>>
Sample Code for the lesson
>>> x = 56
>>> y = 76
>>> z = 76 - 20
>>> x is y
False
>>> x is z
True
>>> x is not z
False
>>> x is not y
True
>>> # Membership Operators
>>> name = "Ramesh"
>>> "es" in name # is es in Ramesh
True
>>> "hi" in name
False
>>> ml = [45,46,67]
>>> 46 in ml
True
>>> 45 not in ml
False
>>> 50 in ml
False
>>> attendance = ["mohan", "sohan", "rohan", "sunil"]
>>> "geeta" in attendance
False
>>> if("geeta" not in attendance):
print("geeta was absent")
geeta was absent
>>> 0 & 1
0
>>> 0001 & 1000
SyntaxError: invalid token
>>> 1 & 1
1
>>> 1 & 0
0
>>>
Sample Code:
child1 = {
"name" : "Mohan",
"year" : 2004
}
child2 = {
"name" : "Sohan",
"year" : 2007
}
child3 = {
"name" : "Rohan",
"year" : 2011
}
myfamily = {
"child1" : child1,
"child2" : child2,
"child3" : child3
}
# Nested Dictionary Example :
item = {'Electronics': {'Mobile': {'Smart':['samsung','apple'], 'Feature':['nokia','samsung']}, 'TV': {'LCD', 'LED'}}}
Example Code
x = int(input("Enter number to print table "))
for i in range(1,11):
print(x," x ",i,"=", x*i )
# Paste the code in Editor and Save the file as .py
Go to https://www.anaconda.com/distribution/ and chose as per your computer's operating system.
Here is Sample Code for the lecture:
# Nested For Loop
quality = ['good', 'better', 'best']
thing = ['mobile', 'laptop', 'tv', 'game']
for x in quality:
for y in thing:
print(x,y)
for x in quality:
for y in thing:
print("i have a " + x + " " + y)
# pass Statement
for i in quality:
pass
print(i)
Sample code for taking input from user in Python :
name = input("Enter Name ")
pwd = input("Enter Password ")
age = input("Enter Age")
#print(type(name))
if name == "john" and pwd == "abc":
if int(age) < 18:
print("not allowed")
if int(age) == 15:
print("you are 15")
else:
print("allowed")
print("welcome john")
elif name == "ram" and pwd == "xyz":
print("welcome ram")
else:
print("wrong credentials")
The endswith() method in Python returns True if a string ends with the given suffix otherwise returns False.
greeting = "HelloWorld"
greeting.removeprefix("Hello")
'World'
greeting.removesuffix()
greeting.removesuffix("World")
'Hello'
Please download sample files ( attached as resource )
You can download the HTML file to get the codes and examples in this section. HTML file is in resources.
What you'll learn
Installing Python in your computer
Core Python
Importing Some Modules in Python
Object Oriented Programming in Python
Syllabus - Core Python
Introduction of Python
Installing Python IDEs– Python IDLE and Anaconda
Writing Your First Python Program
Data-types in Python
Variables in Python – Declaration and Use
Typecasting in Python
Operators in Python – Assignment, Logical, Arithmetic etc.
Taking User Input (Console)
Conditional Statements – If else and Nested If else and elif
Python Collections (Arrays) – List, Tuple, Sets and Dictionary
Loops in Python – For Loop, While Loop & Nested Loops
String Manipulation – Basic Operations, Slicing & Functions and Methods
User Defined Functions – Defining, Calling, Types of Functions, Arguments
Lambda Function
Importing Modules – Math Module
Syllabus - Object Oriented Programming in Python
Basics of Object Oriented Programming
Creating Class and Object
Constructors in Python – Parameterized and Non-parameterized
Inheritance in Python
In built class methods and attributes
Multi-Level and Multiple Inheritance
Method Overriding and Data Abstraction
Encapsulation and Polymorphism
This course is for those professionals who want to learn python for software development, web development and data analysis.
If you don't have fundamental knowledge of python, you cannot start software development, web development and data analysis.
Python is a free and open source programming language that is really easy to learn. Python is used in many applications and it has a potential of generating jobs. You should start learning python today.
Learn Core and Advanced Python programming with SQLITE3 and MySQL Database Administration; Create Software / Web Applications.