Professional Documents
Culture Documents
PY_PPT_01
PY_PPT_01
on
Python Coding with Application Projects & Solutions
Hands-on Course
on
Python Coding with Application Projects & Solutions
Complete Hands-on Sessions
Summary :
Many in-built
Functions are
present in Python
+
PC Software Installation:
Software Installation Link
PC Software Installation:
Software Installation Link
Android APP Installation:
1. Pydroid 3
Jupyter Notebook:
Click on
“Jupyter
Notebook(Anaconda3)”
Example:
a = 100
print(a)
a 100
Rules of Defining Variable:
1. No command or Keyword for declaring a variable.
int a = 100
Ex:
Val = 10
5. Variables are Case-Sensitive val = 100
Note: Val & val are different
Python Built-in Data Types
int (Integer):
a=5
Students = 40
print(type(a))
Temp = 27.52
Output:
<class 'float'>
String (str):
Msg = ‘INDIA’
Msg = “INDIA”
Python Program
a = “Python Programming”
print(a)
print(type(a))
Boolean:
It has two boolean values True or False.
Python Program :
Output :
True
Input & Output Functions
Msg = input()
print(Msg)
Print Function Types:
“$get hello,123|^result=”
int float
str
● int() - Used to Convert any type of data into int data type
● float() - Used to Convert any type of data into float data type
● str() - Used to Convert any type of data into string data type
Python Type Casting:
Ex-2 Integers:
Ex-2 String:
y = int(2.8) # y will be 2
y = str(2) # y will be '2'
z = int("3") # z will be 3 z = str(3.0) # z will be '3.0'
print(y, z)
Ex-2 Float:
x = float(1) # x will be 1.0
+ Addition x+y
- Subtraction x-y
* Multiplication x*y
/ Division x/y
** Exponentiation x ** y
P-1 Simple Calculator using Arithmetic operators:
a = int(input(“Enter a: ”))
b = int(input(“Enter b: ”))
Sum = a+b
Diff = a-b
Product = a*b
Division = a/b
print(sum)
print(Diff)
print(Product)
print(Division)
P-2 Area of Circle:
Python Code:
diameter = 2
pi = 3.14
Area = pi/4 * (diameter**2)
print(Area)
P-3 Volume and Surface Area of Cylinder:
Problem Statement:
For given radius(r) and height(h), calculate Volume & Surface Area of a Cylinder
Assume, r = 3 & h = 10
P-3 Python Code:
pi = 3.14
r=4
h = 10
volume = pi * r * r * h
Surface_Area = 2 * (pi * r * r) + 2 * (pi * r * h)
print(volume, Surface_Area)
Some important parameters:
Multiple Assignments:
You can assign to multiple names at the same time.
Ex: x, y = 2, 3
!= Not Equal X != Y
Slow down
Break ON
ON
If statement
If statement
Syntax:
if (condition):
Application code
Main Code
When Sensor detects,
Motor Pump will ON
card = 1
if (card == 1):
This is an error. print("Do transaction")
print("Show Advertisements")
If else: Syntax:
if (conditions):
Robert Statement 1
John
else:
Statement 2
Age is 6 Age is 5
1 2
3 4
If elif else: Coffee Machine: Python Code
Syntax:
If (condition-1):
Statement-1
Statement-2
……..
elif (condition-2):
Statement-3
Statement-4
else:
Statement-5
P-4 Comparision of Two Numbers:
Code:
a = 33 Output:
if b > a:
elif a == b:
else:
Syntax:
if (condition-1):
Statement-1
if(condition_A):
Statement-2 Inner
Outer
if else: if
Statement-3
else:
Statement-4
Nested if else:
Money Given = 0 Money Given < 5000 Money Given >= 5000
{
ello
a = “Hello World”
index 0 12 ... 10
a = "Hello, World!"
b = a[1:5]
print(b)
P-5 Number Plate Recognition: Toll Gate Application
To Be learnt
➔ Logical Operators
➔ Loops
➔ Structured Data types - Lists, Tuples & Dictionaries
➔ Functions
➔ Python Libraries
String Operations:
len():
Built-in Functions
➔ len()
➔ type()
➔ .upper()
➔ .lower() upper() & lower():
➔ .strip()
➔ .replace(a,b)
Logical Operators:
and Returns True if both statements are true x < 5 and x < 10
Covid-19
Python Code:
‘or’ use case:
Python Code:
AND Operation:
Switch1
Control
System
Switch2
Motor
OFF
ON
P-7 Code:
Approach-1 Approach-2
P-7 Code:
Approach-3
P-8 Body Mass Index (BMI) Calculator :