SlideShare a Scribd company logo
Chapter 1 Basic Programming (Python Programming Lecture)
PYTHON
PROGRAMMING
Chapter 1
Basic Programming
Topic
• Operator
• Arithmetic Operation
• Assignment Operation
• Arithmetic Operation More Example
• More Built in Function Example
• More Math Module Example
Operator in Python
• Operators are special symbols in that carry out arithmetic or logical
computation.
• The value that the operator operates on is called the operand.
• Type of Operator in Python
• Arithmetic operators
• Assignment operators
• Comparison operators
• Logical operators
• Bitwise operators
• Identity operators
• Membership operators
PYTHON
PROGRAMMING
Chapter 1
Lecture 1.1.0
Basic Arithmetic Operator
Arithmetic Operator in Python
Operation Operator
Addition +
Subtraction -
Multiplication *
Division /
Floor Division //
Exponentiation **
Modulo %
Assignment Operator in Python
Operation Operator
Assign =
Add AND Assign +=
Subtract AND Assign -=
Multiply AND Assign *=
Divide AND Assign /=
Modulus AND Assign %=
Exponent AND Assign **=
Floor Division Assign //=
Note: Logical and Bitwise Operator can be used with assignment.
Summation of two number
a = 5
b = 4
sum = a + b
print(sum)
Summation of two number – User Input
a = int(input())
b = int(input())
sum = a + b
print(sum)
Difference of two number
a = int(input())
b = int(input())
diff = a - b
print(diff)
Product of two number
a = int(input())
b = int(input())
pro = a * b
print(pro)
Quotient of two number
a = int(input())
b = int(input())
quo = a / b
print(quo)
Reminder of two number
a = int(input())
b = int(input())
rem = a % b
print(rem)
Practice Problem 1.1
Input two Number form User and calculate the followings:
1. Summation of two number
2. Difference of two number
3. Product of two number
4. Quotient of two number
5. Reminder of two number
Any Question?
Like, Comment, Share
Subscribe
Chapter 1 Basic Programming (Python Programming Lecture)
PYTHON
PROGRAMMING
Chapter 1
Lecture 1.1.1
More Arithmetic Operator
Floor Division
a = int(input())
b = int(input())
floor_div = a // b
print(floor_div)
a = float(input())
b = float(input())
floor_div = a // b
print(floor_div)
a = 5
b = 2
quo = a/b
= 5/2
= 2.5
quo = floor(a/b)
= floor(5/2)
= floor(2.5)
= 2
Find Exponent (a^b). [1]
a = int(input())
b = int(input())
# Exponent with Arithmetic Operator
# Syntax: base ** exponent
exp = a ** b
print(exp)
Find Exponent (a^b). [2]
a = int(input())
b = int(input())
# Exponent with Built-in Function
# Syntax: pow(base, exponent)
exp = pow(a,b)
print(exp)
Find Exponent (a^b). [3]
a = int (input())
b = int(input())
# Return Modulo for Exponent with Built-in Function
# Syntax: pow(base, exponent, modulo)
exp = pow(a,b,2)
print(exp)
a = 2
b = 4
ans = (a^b)%6
= (2^4)%6
= 16%6
= 4
Find Exponent (a^b). [4]
a = int(input())
b = int(input())
# Using Math Module
import math
exp = math.pow(a,b)
print(exp)
Find absolute difference of two number. [1]
a = int(input())
b = int(input())
abs_dif = abs(a - b)
print(abs_dif)
a = 4
b = 2
ans1 = abs(a-b)
= abs(4-2)
= abs(2)
= 2
ans2 = abs(b-a)
= abs(2-4)
= abs(-2)
= 2
Find absolute difference of two number. [2]
import math
a = float(input())
b = float(input())
fabs_dif = math.fabs(a - b)
print(fabs_dif)
Built-in Function
• abs(x)
• pow(x,y[,z])
https://docs.python.org/3.7/library/functions.html
Practice Problem 1.2
Input two number from user and calculate the followings: (use
necessary date type)
1. Floor Division with Integer Number & Float Number
2. Find Exponential (a^b) using Exponent Operator, Built-in
pow function & Math Module pow function
3. Find Exponent with modulo (a^b%c)
4. Find absolute difference of two number using Built-in
abs function & Math Module fabs function
Any Question?
Like, Comment, Share
Subscribe
Chapter 1 Basic Programming (Python Programming Lecture)
PYTHON
PROGRAMMING
Chapter 1
Lecture 1.2
Arithmetic Operation Example
Average of three numbers.
a = float(input())
b = float(input())
c = float(input())
sum = a + b + c
avg = sum/3
print(avg)
Area of Triangle using Base and Height.
b = float(input())
h = float(input())
area = (1/2) * b * h
print(area)
Area of Triangle using Length of 3 sides.
import math
a = float(input())
b = float(input())
c = float(input())
s = (a+b+c) / 2
area = math.sqrt(s*(s-a)*(s-b)*(s-c))
print(area)
𝑎𝑟𝑒𝑎 = 𝑠 ∗ (s−a)∗(s−b)∗(s−c)
𝑠 =
𝑎 + 𝑏 + 𝑐
2
Area of Circle using Radius.
import math
r = float(input())
pi = math.pi
area = pi * r**2
# area = pi * pow(r,2)
print(area)
𝑎𝑟𝑒𝑎 = 3.1416 ∗ 𝑟2
Convert Temperature Celsius to Fahrenheit.
celsius = float(input())
fahrenheit = (celsius*9)/5 + 32
print(fahrenheit)
𝐶
5
=
𝐹 − 32
9
𝐹 − 32 ∗ 5 = 𝐶 ∗ 9
𝐹 − 32 =
𝐶 ∗ 9
5
𝐹 =
𝐶 ∗ 9
5
+ 32
Convert Temperature Fahrenheit to Celsius.
fahrenheit = float(input())
celsius = (fahrenheit-32)/9 * 5
print(celsius)
𝐶
5
=
𝐹 − 32
9
𝐶 ∗ 9 = 𝐹 − 32 ∗ 5
𝐶 =
𝐹 − 32 ∗ 5
9
Convert Second to HH:MM:SS.
# 1 Hour = 3600 Seconds
# 1 Minute = 60 Seconds
totalSec = int(input())
hour = int(totalSec/3600)
min_sec = int(totalSec%3600)
minute = int(min_sec/60)
second = int(min_sec%60)
print("{}H {}M
{}S".format(hour,minute,second))
#print(f"{hour}H {minute}M {second}S")
# 1 Hour = 3600 Seconds
# 1 Minute = 60 Seconds
totalSec = int(input())
hour = totalSec//3600
min_sec = totalSec%3600
minute = min_sec//60
second = min_sec%60
print("{}H {}M
{}S".format(hour,minute,second))
#print(f"{hour}H {minute}M {second}S")
Math Module
• math.pow(x, y)
• math.sqrt(x)
• math.pi
https://docs.python.org/3.7/library/math.html
Practice Problem 1.3
1. Average of three numbers.
2. Area of Triangle using Base and Height.
3. Area of Triangle using Length of 3 sides.
4. Area of Circle using Radius.
5. Convert Temperature Celsius to Fahrenheit.
6. Convert Temperature Fahrenheit to Celsius.
7. Convert Second to HH:MM:SS.
Any Question?
Like, Comment, Share
Subscribe
Chapter 1 Basic Programming (Python Programming Lecture)
PYTHON
PROGRAMMING
Chapter 1
Lecture 1.2
More Operator
Comparison Operator in Python
Operation Operator
Equality ==
Not Equal !=
Greater Than >
Less Than <
Greater or Equal >=
Less or Equal <=
Logical Operator in Python
Operation Operator
Logical And and
Logical Or or
Logical Not not
Bitwise Operator in Python
Operation Operator
Bitwise And &
Bitwise Or |
Bitwise Xor ^
Left Shift <<
Right Shift >>
Other Operator in Python
• Membership Operator (in, not in)
• Identity Operator (is, not is)
Any Question?
Like, Comment, Share
Subscribe
Chapter 1 Basic Programming (Python Programming Lecture)

More Related Content

What's hot (20)

Pointers C programming
Pointers  C programmingPointers  C programming
Pointers C programming
Appili Vamsi Krishna
 
Tkinter Python Tutorial | Python GUI Programming Using Tkinter Tutorial | Pyt...
Tkinter Python Tutorial | Python GUI Programming Using Tkinter Tutorial | Pyt...Tkinter Python Tutorial | Python GUI Programming Using Tkinter Tutorial | Pyt...
Tkinter Python Tutorial | Python GUI Programming Using Tkinter Tutorial | Pyt...
Edureka!
 
Pointer in c
Pointer in cPointer in c
Pointer in c
lavanya marichamy
 
An Introduction to Python Concurrency
An Introduction to Python ConcurrencyAn Introduction to Python Concurrency
An Introduction to Python Concurrency
David Beazley (Dabeaz LLC)
 
Data structures and algorithms
Data structures and algorithmsData structures and algorithms
Data structures and algorithms
Julie Iskander
 
Cryptography
CryptographyCryptography
Cryptography
jayashri kolekar
 
Operators in python
Operators in pythonOperators in python
Operators in python
Prabhakaran V M
 
Circular link list.ppt
Circular link list.pptCircular link list.ppt
Circular link list.ppt
Tirthika Bandi
 
Hash tables
Hash tablesHash tables
Hash tables
Rajendran
 
Function in C program
Function in C programFunction in C program
Function in C program
Nurul Zakiah Zamri Tan
 
Pointer in c program
Pointer in c programPointer in c program
Pointer in c program
Rumman Ansari
 
stack presentation
stack presentationstack presentation
stack presentation
Shivalik college of engineering
 
Classes and objects
Classes and objectsClasses and objects
Classes and objects
Nilesh Dalvi
 
PHP FUNCTIONS
PHP FUNCTIONSPHP FUNCTIONS
PHP FUNCTIONS
Zeeshan Ahmed
 
GE8151 Problem Solving and Python Programming
GE8151 Problem Solving and Python ProgrammingGE8151 Problem Solving and Python Programming
GE8151 Problem Solving and Python Programming
Muthu Vinayagam
 
Unit 3. Input and Output
Unit 3. Input and OutputUnit 3. Input and Output
Unit 3. Input and Output
Ashim Lamichhane
 
Parsing in Compiler Design
Parsing in Compiler DesignParsing in Compiler Design
Parsing in Compiler Design
Akhil Kaushik
 
Namespaces
NamespacesNamespaces
Namespaces
Sangeetha S
 
Data Structures- Part5 recursion
Data Structures- Part5 recursionData Structures- Part5 recursion
Data Structures- Part5 recursion
Abdullah Al-hazmy
 
Time complexity
Time complexityTime complexity
Time complexity
Katang Isip
 

Similar to Chapter 1 Basic Programming (Python Programming Lecture) (20)

Lecture 1 python arithmetic (ewurc)
Lecture 1 python arithmetic (ewurc)Lecture 1 python arithmetic (ewurc)
Lecture 1 python arithmetic (ewurc)
Al-Mamun Riyadh (Mun)
 
Strings in python are surrounded by eith
Strings in python are surrounded by eithStrings in python are surrounded by eith
Strings in python are surrounded by eith
Orin18
 
Lecture 5 – Computing with Numbers (Math Lib).pptx
Lecture 5 – Computing with Numbers (Math Lib).pptxLecture 5 – Computing with Numbers (Math Lib).pptx
Lecture 5 – Computing with Numbers (Math Lib).pptx
jovannyflex
 
Lecture 5 – Computing with Numbers (Math Lib).pptx
Lecture 5 – Computing with Numbers (Math Lib).pptxLecture 5 – Computing with Numbers (Math Lib).pptx
Lecture 5 – Computing with Numbers (Math Lib).pptx
jovannyflex
 
OPERATORS-PYTHON.pptx ALL OPERATORS ARITHMATIC AND LOGICAL
OPERATORS-PYTHON.pptx   ALL OPERATORS ARITHMATIC AND LOGICALOPERATORS-PYTHON.pptx   ALL OPERATORS ARITHMATIC AND LOGICAL
OPERATORS-PYTHON.pptx ALL OPERATORS ARITHMATIC AND LOGICAL
NagarathnaRajur2
 
Some hours of python
Some hours of pythonSome hours of python
Some hours of python
Things Lab
 
Python From Scratch (1).pdf
Python From Scratch  (1).pdfPython From Scratch  (1).pdf
Python From Scratch (1).pdf
NeerajChauhan697157
 
Python : basic operators
Python : basic operatorsPython : basic operators
Python : basic operators
S.M. Salaquzzaman
 
Python
PythonPython
Python
Pooriya Kazemzadeh-Heris
 
Python Laboratory Programming Manual.docx
Python Laboratory Programming Manual.docxPython Laboratory Programming Manual.docx
Python Laboratory Programming Manual.docx
ShylajaS14
 
introduction to python programming course 2
introduction to python programming course 2introduction to python programming course 2
introduction to python programming course 2
FarhadMohammadRezaHa
 
python lab programs.pdf
python lab programs.pdfpython lab programs.pdf
python lab programs.pdf
CBJWorld
 
Class 2: Welcome part 2
Class 2: Welcome part 2Class 2: Welcome part 2
Class 2: Welcome part 2
Marc Gouw
 
PYTHON
PYTHONPYTHON
PYTHON
RidaZaman1
 
2. data types, variables and operators
2. data types, variables and operators2. data types, variables and operators
2. data types, variables and operators
PhD Research Scholar
 
(2 - 1) CSE1021 - Module 2 Worksheet.pdf
(2 - 1) CSE1021 - Module 2 Worksheet.pdf(2 - 1) CSE1021 - Module 2 Worksheet.pdf
(2 - 1) CSE1021 - Module 2 Worksheet.pdf
ayushagar5185
 
Python.pptx
Python.pptxPython.pptx
Python.pptx
AKANSHAMITTAL2K21AFI
 
PPt Revision of the basics of python1.pptx
PPt Revision of the basics of python1.pptxPPt Revision of the basics of python1.pptx
PPt Revision of the basics of python1.pptx
tcsonline1222
 
02sjjknbjijnuijkjnkggjknbhhbjkjhnilide.ppt
02sjjknbjijnuijkjnkggjknbhhbjkjhnilide.ppt02sjjknbjijnuijkjnkggjknbhhbjkjhnilide.ppt
02sjjknbjijnuijkjnkggjknbhhbjkjhnilide.ppt
KhanhPhan575445
 
cel shading as PDF and Python description
cel shading as PDF and Python descriptioncel shading as PDF and Python description
cel shading as PDF and Python description
MarcosLuis32
 
Strings in python are surrounded by eith
Strings in python are surrounded by eithStrings in python are surrounded by eith
Strings in python are surrounded by eith
Orin18
 
Lecture 5 – Computing with Numbers (Math Lib).pptx
Lecture 5 – Computing with Numbers (Math Lib).pptxLecture 5 – Computing with Numbers (Math Lib).pptx
Lecture 5 – Computing with Numbers (Math Lib).pptx
jovannyflex
 
Lecture 5 – Computing with Numbers (Math Lib).pptx
Lecture 5 – Computing with Numbers (Math Lib).pptxLecture 5 – Computing with Numbers (Math Lib).pptx
Lecture 5 – Computing with Numbers (Math Lib).pptx
jovannyflex
 
OPERATORS-PYTHON.pptx ALL OPERATORS ARITHMATIC AND LOGICAL
OPERATORS-PYTHON.pptx   ALL OPERATORS ARITHMATIC AND LOGICALOPERATORS-PYTHON.pptx   ALL OPERATORS ARITHMATIC AND LOGICAL
OPERATORS-PYTHON.pptx ALL OPERATORS ARITHMATIC AND LOGICAL
NagarathnaRajur2
 
Some hours of python
Some hours of pythonSome hours of python
Some hours of python
Things Lab
 
Python Laboratory Programming Manual.docx
Python Laboratory Programming Manual.docxPython Laboratory Programming Manual.docx
Python Laboratory Programming Manual.docx
ShylajaS14
 
introduction to python programming course 2
introduction to python programming course 2introduction to python programming course 2
introduction to python programming course 2
FarhadMohammadRezaHa
 
python lab programs.pdf
python lab programs.pdfpython lab programs.pdf
python lab programs.pdf
CBJWorld
 
Class 2: Welcome part 2
Class 2: Welcome part 2Class 2: Welcome part 2
Class 2: Welcome part 2
Marc Gouw
 
2. data types, variables and operators
2. data types, variables and operators2. data types, variables and operators
2. data types, variables and operators
PhD Research Scholar
 
(2 - 1) CSE1021 - Module 2 Worksheet.pdf
(2 - 1) CSE1021 - Module 2 Worksheet.pdf(2 - 1) CSE1021 - Module 2 Worksheet.pdf
(2 - 1) CSE1021 - Module 2 Worksheet.pdf
ayushagar5185
 
PPt Revision of the basics of python1.pptx
PPt Revision of the basics of python1.pptxPPt Revision of the basics of python1.pptx
PPt Revision of the basics of python1.pptx
tcsonline1222
 
02sjjknbjijnuijkjnkggjknbhhbjkjhnilide.ppt
02sjjknbjijnuijkjnkggjknbhhbjkjhnilide.ppt02sjjknbjijnuijkjnkggjknbhhbjkjhnilide.ppt
02sjjknbjijnuijkjnkggjknbhhbjkjhnilide.ppt
KhanhPhan575445
 
cel shading as PDF and Python description
cel shading as PDF and Python descriptioncel shading as PDF and Python description
cel shading as PDF and Python description
MarcosLuis32
 
Ad

More from IoT Code Lab (8)

7.1 html lec 7
7.1 html lec 77.1 html lec 7
7.1 html lec 7
IoT Code Lab
 
6.1 html lec 6
6.1 html lec 66.1 html lec 6
6.1 html lec 6
IoT Code Lab
 
5.1 html lec 5
5.1 html lec 55.1 html lec 5
5.1 html lec 5
IoT Code Lab
 
4.1 html lec 4
4.1 html lec 44.1 html lec 4
4.1 html lec 4
IoT Code Lab
 
3.1 html lec 3
3.1 html lec 33.1 html lec 3
3.1 html lec 3
IoT Code Lab
 
2.1 html lec 2
2.1 html lec 22.1 html lec 2
2.1 html lec 2
IoT Code Lab
 
1.1 html lec 1
1.1 html lec 11.1 html lec 1
1.1 html lec 1
IoT Code Lab
 
1.0 intro
1.0 intro1.0 intro
1.0 intro
IoT Code Lab
 
Ad

Recently uploaded (20)

State institute of educational technology
State institute of educational technologyState institute of educational technology
State institute of educational technology
vp5806484
 
Webcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Webcrawler_Mule_AIChain_MuleSoft_Meetup_HyderabadWebcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Webcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Veera Pallapu
 
MATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKANMATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKAN
aditya23173
 
Rai dyansty Chach or Brahamn dynasty, History of Dahir History of Sindh NEP.pptx
Rai dyansty Chach or Brahamn dynasty, History of Dahir History of Sindh NEP.pptxRai dyansty Chach or Brahamn dynasty, History of Dahir History of Sindh NEP.pptx
Rai dyansty Chach or Brahamn dynasty, History of Dahir History of Sindh NEP.pptx
Dr. Ravi Shankar Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
 
LDMMIA Free Reiki Yoga S9 Grad Level Intuition II
LDMMIA Free Reiki Yoga S9 Grad Level Intuition IILDMMIA Free Reiki Yoga S9 Grad Level Intuition II
LDMMIA Free Reiki Yoga S9 Grad Level Intuition II
LDM & Mia eStudios
 
Different pricelists for different shops in odoo Point of Sale in Odoo 17
Different pricelists for different shops in odoo Point of Sale in Odoo 17Different pricelists for different shops in odoo Point of Sale in Odoo 17
Different pricelists for different shops in odoo Point of Sale in Odoo 17
Celine George
 
EUPHORIA GENERAL QUIZ FINALS | QUIZ CLUB OF PSGCAS | 21 MARCH 2025
EUPHORIA GENERAL QUIZ FINALS | QUIZ CLUB OF PSGCAS | 21 MARCH 2025EUPHORIA GENERAL QUIZ FINALS | QUIZ CLUB OF PSGCAS | 21 MARCH 2025
EUPHORIA GENERAL QUIZ FINALS | QUIZ CLUB OF PSGCAS | 21 MARCH 2025
Quiz Club of PSG College of Arts & Science
 
POS Reporting in Odoo 18 - Odoo 18 Slides
POS Reporting in Odoo 18 - Odoo 18 SlidesPOS Reporting in Odoo 18 - Odoo 18 Slides
POS Reporting in Odoo 18 - Odoo 18 Slides
Celine George
 
la storia dell'Inghilterra, letteratura inglese
la storia dell'Inghilterra, letteratura inglesela storia dell'Inghilterra, letteratura inglese
la storia dell'Inghilterra, letteratura inglese
LetiziaLucente
 
LDMMIA Reiki Yoga S8 Free Workshop Grad Level
LDMMIA Reiki Yoga S8 Free Workshop Grad LevelLDMMIA Reiki Yoga S8 Free Workshop Grad Level
LDMMIA Reiki Yoga S8 Free Workshop Grad Level
LDM & Mia eStudios
 
Hemiptera & Neuroptera: Insect Diversity.pptx
Hemiptera & Neuroptera: Insect Diversity.pptxHemiptera & Neuroptera: Insect Diversity.pptx
Hemiptera & Neuroptera: Insect Diversity.pptx
Arshad Shaikh
 
Cloud Computing ..PPT ( Faizan ALTAF )..
Cloud Computing ..PPT ( Faizan ALTAF )..Cloud Computing ..PPT ( Faizan ALTAF )..
Cloud Computing ..PPT ( Faizan ALTAF )..
faizanaltaf231
 
Fatman Book HD Pdf by aayush songare.pdf
Fatman Book  HD Pdf by aayush songare.pdfFatman Book  HD Pdf by aayush songare.pdf
Fatman Book HD Pdf by aayush songare.pdf
Aayush Songare
 
Unit 3 Poster Sketches with annotations.pptx
Unit 3 Poster Sketches with annotations.pptxUnit 3 Poster Sketches with annotations.pptx
Unit 3 Poster Sketches with annotations.pptx
bobby205207
 
Analysis of Quantitative Data Parametric and non-parametric tests.pptx
Analysis of Quantitative Data Parametric and non-parametric tests.pptxAnalysis of Quantitative Data Parametric and non-parametric tests.pptx
Analysis of Quantitative Data Parametric and non-parametric tests.pptx
Shrutidhara2
 
SEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptx
SEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptxSEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptx
SEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptx
PoojaSen20
 
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
parmarjuli1412
 
Forestry Model Exit Exam_2025_Wollega University, Gimbi Campus.pdf
Forestry Model Exit Exam_2025_Wollega University, Gimbi Campus.pdfForestry Model Exit Exam_2025_Wollega University, Gimbi Campus.pdf
Forestry Model Exit Exam_2025_Wollega University, Gimbi Campus.pdf
ChalaKelbessa
 
IDSP(INTEGRATED DISEASE SURVEILLANCE PROGRAMME...
IDSP(INTEGRATED DISEASE SURVEILLANCE PROGRAMME...IDSP(INTEGRATED DISEASE SURVEILLANCE PROGRAMME...
IDSP(INTEGRATED DISEASE SURVEILLANCE PROGRAMME...
SweetytamannaMohapat
 
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKANMATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
aditya23173
 
State institute of educational technology
State institute of educational technologyState institute of educational technology
State institute of educational technology
vp5806484
 
Webcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Webcrawler_Mule_AIChain_MuleSoft_Meetup_HyderabadWebcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Webcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Veera Pallapu
 
MATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKANMATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 4 LANDASAN FILOSOFIS PENDIDIKAN
aditya23173
 
LDMMIA Free Reiki Yoga S9 Grad Level Intuition II
LDMMIA Free Reiki Yoga S9 Grad Level Intuition IILDMMIA Free Reiki Yoga S9 Grad Level Intuition II
LDMMIA Free Reiki Yoga S9 Grad Level Intuition II
LDM & Mia eStudios
 
Different pricelists for different shops in odoo Point of Sale in Odoo 17
Different pricelists for different shops in odoo Point of Sale in Odoo 17Different pricelists for different shops in odoo Point of Sale in Odoo 17
Different pricelists for different shops in odoo Point of Sale in Odoo 17
Celine George
 
POS Reporting in Odoo 18 - Odoo 18 Slides
POS Reporting in Odoo 18 - Odoo 18 SlidesPOS Reporting in Odoo 18 - Odoo 18 Slides
POS Reporting in Odoo 18 - Odoo 18 Slides
Celine George
 
la storia dell'Inghilterra, letteratura inglese
la storia dell'Inghilterra, letteratura inglesela storia dell'Inghilterra, letteratura inglese
la storia dell'Inghilterra, letteratura inglese
LetiziaLucente
 
LDMMIA Reiki Yoga S8 Free Workshop Grad Level
LDMMIA Reiki Yoga S8 Free Workshop Grad LevelLDMMIA Reiki Yoga S8 Free Workshop Grad Level
LDMMIA Reiki Yoga S8 Free Workshop Grad Level
LDM & Mia eStudios
 
Hemiptera & Neuroptera: Insect Diversity.pptx
Hemiptera & Neuroptera: Insect Diversity.pptxHemiptera & Neuroptera: Insect Diversity.pptx
Hemiptera & Neuroptera: Insect Diversity.pptx
Arshad Shaikh
 
Cloud Computing ..PPT ( Faizan ALTAF )..
Cloud Computing ..PPT ( Faizan ALTAF )..Cloud Computing ..PPT ( Faizan ALTAF )..
Cloud Computing ..PPT ( Faizan ALTAF )..
faizanaltaf231
 
Fatman Book HD Pdf by aayush songare.pdf
Fatman Book  HD Pdf by aayush songare.pdfFatman Book  HD Pdf by aayush songare.pdf
Fatman Book HD Pdf by aayush songare.pdf
Aayush Songare
 
Unit 3 Poster Sketches with annotations.pptx
Unit 3 Poster Sketches with annotations.pptxUnit 3 Poster Sketches with annotations.pptx
Unit 3 Poster Sketches with annotations.pptx
bobby205207
 
Analysis of Quantitative Data Parametric and non-parametric tests.pptx
Analysis of Quantitative Data Parametric and non-parametric tests.pptxAnalysis of Quantitative Data Parametric and non-parametric tests.pptx
Analysis of Quantitative Data Parametric and non-parametric tests.pptx
Shrutidhara2
 
SEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptx
SEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptxSEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptx
SEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptx
PoojaSen20
 
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
THERAPEUTIC COMMUNICATION included definition, characteristics, nurse patient...
parmarjuli1412
 
Forestry Model Exit Exam_2025_Wollega University, Gimbi Campus.pdf
Forestry Model Exit Exam_2025_Wollega University, Gimbi Campus.pdfForestry Model Exit Exam_2025_Wollega University, Gimbi Campus.pdf
Forestry Model Exit Exam_2025_Wollega University, Gimbi Campus.pdf
ChalaKelbessa
 
IDSP(INTEGRATED DISEASE SURVEILLANCE PROGRAMME...
IDSP(INTEGRATED DISEASE SURVEILLANCE PROGRAMME...IDSP(INTEGRATED DISEASE SURVEILLANCE PROGRAMME...
IDSP(INTEGRATED DISEASE SURVEILLANCE PROGRAMME...
SweetytamannaMohapat
 
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKANMATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
aditya23173
 

Chapter 1 Basic Programming (Python Programming Lecture)

  • 3. Topic • Operator • Arithmetic Operation • Assignment Operation • Arithmetic Operation More Example • More Built in Function Example • More Math Module Example
  • 4. Operator in Python • Operators are special symbols in that carry out arithmetic or logical computation. • The value that the operator operates on is called the operand. • Type of Operator in Python • Arithmetic operators • Assignment operators • Comparison operators • Logical operators • Bitwise operators • Identity operators • Membership operators
  • 6. Arithmetic Operator in Python Operation Operator Addition + Subtraction - Multiplication * Division / Floor Division // Exponentiation ** Modulo %
  • 7. Assignment Operator in Python Operation Operator Assign = Add AND Assign += Subtract AND Assign -= Multiply AND Assign *= Divide AND Assign /= Modulus AND Assign %= Exponent AND Assign **= Floor Division Assign //= Note: Logical and Bitwise Operator can be used with assignment.
  • 8. Summation of two number a = 5 b = 4 sum = a + b print(sum)
  • 9. Summation of two number – User Input a = int(input()) b = int(input()) sum = a + b print(sum)
  • 10. Difference of two number a = int(input()) b = int(input()) diff = a - b print(diff)
  • 11. Product of two number a = int(input()) b = int(input()) pro = a * b print(pro)
  • 12. Quotient of two number a = int(input()) b = int(input()) quo = a / b print(quo)
  • 13. Reminder of two number a = int(input()) b = int(input()) rem = a % b print(rem)
  • 14. Practice Problem 1.1 Input two Number form User and calculate the followings: 1. Summation of two number 2. Difference of two number 3. Product of two number 4. Quotient of two number 5. Reminder of two number
  • 15. Any Question? Like, Comment, Share Subscribe
  • 18. Floor Division a = int(input()) b = int(input()) floor_div = a // b print(floor_div) a = float(input()) b = float(input()) floor_div = a // b print(floor_div) a = 5 b = 2 quo = a/b = 5/2 = 2.5 quo = floor(a/b) = floor(5/2) = floor(2.5) = 2
  • 19. Find Exponent (a^b). [1] a = int(input()) b = int(input()) # Exponent with Arithmetic Operator # Syntax: base ** exponent exp = a ** b print(exp)
  • 20. Find Exponent (a^b). [2] a = int(input()) b = int(input()) # Exponent with Built-in Function # Syntax: pow(base, exponent) exp = pow(a,b) print(exp)
  • 21. Find Exponent (a^b). [3] a = int (input()) b = int(input()) # Return Modulo for Exponent with Built-in Function # Syntax: pow(base, exponent, modulo) exp = pow(a,b,2) print(exp) a = 2 b = 4 ans = (a^b)%6 = (2^4)%6 = 16%6 = 4
  • 22. Find Exponent (a^b). [4] a = int(input()) b = int(input()) # Using Math Module import math exp = math.pow(a,b) print(exp)
  • 23. Find absolute difference of two number. [1] a = int(input()) b = int(input()) abs_dif = abs(a - b) print(abs_dif) a = 4 b = 2 ans1 = abs(a-b) = abs(4-2) = abs(2) = 2 ans2 = abs(b-a) = abs(2-4) = abs(-2) = 2
  • 24. Find absolute difference of two number. [2] import math a = float(input()) b = float(input()) fabs_dif = math.fabs(a - b) print(fabs_dif)
  • 25. Built-in Function • abs(x) • pow(x,y[,z]) https://docs.python.org/3.7/library/functions.html
  • 26. Practice Problem 1.2 Input two number from user and calculate the followings: (use necessary date type) 1. Floor Division with Integer Number & Float Number 2. Find Exponential (a^b) using Exponent Operator, Built-in pow function & Math Module pow function 3. Find Exponent with modulo (a^b%c) 4. Find absolute difference of two number using Built-in abs function & Math Module fabs function
  • 27. Any Question? Like, Comment, Share Subscribe
  • 30. Average of three numbers. a = float(input()) b = float(input()) c = float(input()) sum = a + b + c avg = sum/3 print(avg)
  • 31. Area of Triangle using Base and Height. b = float(input()) h = float(input()) area = (1/2) * b * h print(area)
  • 32. Area of Triangle using Length of 3 sides. import math a = float(input()) b = float(input()) c = float(input()) s = (a+b+c) / 2 area = math.sqrt(s*(s-a)*(s-b)*(s-c)) print(area) 𝑎𝑟𝑒𝑎 = 𝑠 ∗ (s−a)∗(s−b)∗(s−c) 𝑠 = 𝑎 + 𝑏 + 𝑐 2
  • 33. Area of Circle using Radius. import math r = float(input()) pi = math.pi area = pi * r**2 # area = pi * pow(r,2) print(area) 𝑎𝑟𝑒𝑎 = 3.1416 ∗ 𝑟2
  • 34. Convert Temperature Celsius to Fahrenheit. celsius = float(input()) fahrenheit = (celsius*9)/5 + 32 print(fahrenheit) 𝐶 5 = 𝐹 − 32 9 𝐹 − 32 ∗ 5 = 𝐶 ∗ 9 𝐹 − 32 = 𝐶 ∗ 9 5 𝐹 = 𝐶 ∗ 9 5 + 32
  • 35. Convert Temperature Fahrenheit to Celsius. fahrenheit = float(input()) celsius = (fahrenheit-32)/9 * 5 print(celsius) 𝐶 5 = 𝐹 − 32 9 𝐶 ∗ 9 = 𝐹 − 32 ∗ 5 𝐶 = 𝐹 − 32 ∗ 5 9
  • 36. Convert Second to HH:MM:SS. # 1 Hour = 3600 Seconds # 1 Minute = 60 Seconds totalSec = int(input()) hour = int(totalSec/3600) min_sec = int(totalSec%3600) minute = int(min_sec/60) second = int(min_sec%60) print("{}H {}M {}S".format(hour,minute,second)) #print(f"{hour}H {minute}M {second}S") # 1 Hour = 3600 Seconds # 1 Minute = 60 Seconds totalSec = int(input()) hour = totalSec//3600 min_sec = totalSec%3600 minute = min_sec//60 second = min_sec%60 print("{}H {}M {}S".format(hour,minute,second)) #print(f"{hour}H {minute}M {second}S")
  • 37. Math Module • math.pow(x, y) • math.sqrt(x) • math.pi https://docs.python.org/3.7/library/math.html
  • 38. Practice Problem 1.3 1. Average of three numbers. 2. Area of Triangle using Base and Height. 3. Area of Triangle using Length of 3 sides. 4. Area of Circle using Radius. 5. Convert Temperature Celsius to Fahrenheit. 6. Convert Temperature Fahrenheit to Celsius. 7. Convert Second to HH:MM:SS.
  • 39. Any Question? Like, Comment, Share Subscribe
  • 42. Comparison Operator in Python Operation Operator Equality == Not Equal != Greater Than > Less Than < Greater or Equal >= Less or Equal <=
  • 43. Logical Operator in Python Operation Operator Logical And and Logical Or or Logical Not not
  • 44. Bitwise Operator in Python Operation Operator Bitwise And & Bitwise Or | Bitwise Xor ^ Left Shift << Right Shift >>
  • 45. Other Operator in Python • Membership Operator (in, not in) • Identity Operator (is, not is)
  • 46. Any Question? Like, Comment, Share Subscribe