SlideShare uma empresa Scribd logo
1 de 27
Baixar para ler offline
Python
Lecture 1
Problem Set 1: Arithmetic
Topic
• Arithmetic Operation
• Operator (Arithmetic Operator)
• More Built in Function
• Module (Math)
• Problem Set 1: Arithmetic (15)
Summation of two number.
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)
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)
Find Exponent (a^b). [4]
a = int(input())
b = int(input())
# Using Math Library
import math
exp = math.pow(a,b)
print(exp)
Floor Division.
a = int(input())
b = int(input())
div = a // b
print(div)
a = float(input())
b = float(input())
div = a // b
print(div)
Find absolute difference of two number. [1]
a = int(input())
b = int(input())
absdif = abs(a - b)
print(absdif)
Find absolute difference of two number. [2]
import math
a = float(input())
b = float(input())
absdif = math.fabs(a - b)
print(absdif)
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)
Area of Circle using Radius.
import math
r = float(input())
pi = math.pi
area = pi * r**2
# area = pi * pow(r,2)
print(area)
Convert Temperature Celsius to Fahrenheit.
# (C/5) = (F-32)/9
celsius = float(input())
fahrenheit = 9 * (celsius/5) + 32
print(fahrenheit)
Convert Temperature Fahrenheit to Celsius.
# (C/5) = (F-32)/9
fahrenheit = float(input())
celsius = (fahrenheit-32)/9 * 5
print(celsius)
Convert Second to HH:MM:SS.
# 1 Hour = 60 Minutes
# 1 Minute = 60 Seconds
totalSec = int(input())
hour = int(totalSec/3600)
remSec = int(totalSec%3600)
minute = int(remSec/60)
second = int(totalSec%60)
print("{}H {}M {}S".format(hour,minute,second))
#print(f"{hour}H {minute}M {second}S")
# 1 Hour = 60 Minutes
# 1 Minute = 60 Seconds
totalSec = int(input())
hour = totalSec//3600
remSec = totalSec%3600
minute = remSec//60
second = totalSec%60
print("{}H {}M {}S".format(hour,minute,second))
#print(f"{hour}H {minute}M {second}S")
Built-in Function
• abs(x)
• pow(x,y)
• https://docs.python.org/3.6/library/functions.html
Math Module
• math.pow(x, y)
• math.sqrt(x)
• math.pi
• https://docs.python.org/3.6/library/math.html
Problem Set 1: Arithmetic (15)
• Summation of two number.
• Difference of two number.
• Product of two number.
• Quotient of two number.
• Reminder of two number.
• Find Exponent (a^b).
• Floor Division.
• Find absolute difference of two
number.
• Average of three numbers.
• Area of Triangle using Base and
Height.
• Area of Triangle using Length of 3
sides.
• Area of Circle using Radius.
• Convert Temperature Celsius to
Fahrenheit.
• Convert Temperature Fahrenheit to
Celsius.
• Convert Second to HH:MM:SS.
Any Question?
Prepared by
Mun Al Mamun
President
East West University Robotics Club
munewu@gmail.com
T h i s s l i d e i s p r o v i d e a s a c o u r s e
m a t e r i a l i n t h e w o r k s h o p
“ W o r k s h o p O n P y t h o n P r o g r a m m i n g ”
O r g a n i z e d b y
E a s t W e s t U n i v e r s i t y R o b o t i c s C l u b

Mais conteúdo relacionado

Mais procurados

4.7 inverse functions.ppt worked
4.7   inverse functions.ppt worked4.7   inverse functions.ppt worked
4.7 inverse functions.ppt workedJonna Ramsey
 
8th alg -l1.3
8th alg -l1.38th alg -l1.3
8th alg -l1.3jdurst65
 
Digital logic circuit
Digital logic circuit Digital logic circuit
Digital logic circuit Prabhu R
 
1.ripple carry adder, full adder implementation using half adder.
1.ripple carry adder, full adder implementation using half adder.1.ripple carry adder, full adder implementation using half adder.
1.ripple carry adder, full adder implementation using half adder.MdFazleRabbi18
 
1.7 composite figures
1.7 composite figures1.7 composite figures
1.7 composite figuresEdmarPrado2
 
1.7 composite figures (1)
1.7 composite figures (1)1.7 composite figures (1)
1.7 composite figures (1)LeizelAlvarez1
 
Obj. 44 Triangles and Quadrilaterals
Obj. 44 Triangles and QuadrilateralsObj. 44 Triangles and Quadrilaterals
Obj. 44 Triangles and Quadrilateralssmiller5
 
Chapter13 two-dimensional-array
Chapter13 two-dimensional-arrayChapter13 two-dimensional-array
Chapter13 two-dimensional-arrayDeepak Singh
 
Asymptotic notation
Asymptotic notationAsymptotic notation
Asymptotic notationsajinis3
 
Basic Geometry Josey1jn
Basic Geometry Josey1jnBasic Geometry Josey1jn
Basic Geometry Josey1jnjosey1jn
 
Ch 7 tutoring notes quadratics
Ch 7 tutoring notes quadraticsCh 7 tutoring notes quadratics
Ch 7 tutoring notes quadraticssrobbins4
 
[Question Paper] Advanced SQL (Old Course) [April / 2015]
[Question Paper] Advanced SQL (Old Course) [April / 2015][Question Paper] Advanced SQL (Old Course) [April / 2015]
[Question Paper] Advanced SQL (Old Course) [April / 2015]Mumbai B.Sc.IT Study
 

Mais procurados (17)

4.7 inverse functions.ppt worked
4.7   inverse functions.ppt worked4.7   inverse functions.ppt worked
4.7 inverse functions.ppt worked
 
8th alg -l1.3
8th alg -l1.38th alg -l1.3
8th alg -l1.3
 
Adder ppt
Adder pptAdder ppt
Adder ppt
 
Digital logic circuit
Digital logic circuit Digital logic circuit
Digital logic circuit
 
1.ripple carry adder, full adder implementation using half adder.
1.ripple carry adder, full adder implementation using half adder.1.ripple carry adder, full adder implementation using half adder.
1.ripple carry adder, full adder implementation using half adder.
 
Module 2 topic 2 notes
Module 2 topic 2 notesModule 2 topic 2 notes
Module 2 topic 2 notes
 
1.7 composite figures
1.7 composite figures1.7 composite figures
1.7 composite figures
 
1.7 composite figures (1)
1.7 composite figures (1)1.7 composite figures (1)
1.7 composite figures (1)
 
Obj. 44 Triangles and Quadrilaterals
Obj. 44 Triangles and QuadrilateralsObj. 44 Triangles and Quadrilaterals
Obj. 44 Triangles and Quadrilaterals
 
Chapter13 two-dimensional-array
Chapter13 two-dimensional-arrayChapter13 two-dimensional-array
Chapter13 two-dimensional-array
 
Asymptotic notation
Asymptotic notationAsymptotic notation
Asymptotic notation
 
Practical no 4
Practical no 4Practical no 4
Practical no 4
 
P13 019
P13 019P13 019
P13 019
 
Basic Geometry Josey1jn
Basic Geometry Josey1jnBasic Geometry Josey1jn
Basic Geometry Josey1jn
 
Ch 7 tutoring notes quadratics
Ch 7 tutoring notes quadraticsCh 7 tutoring notes quadratics
Ch 7 tutoring notes quadratics
 
[Question Paper] Advanced SQL (Old Course) [April / 2015]
[Question Paper] Advanced SQL (Old Course) [April / 2015][Question Paper] Advanced SQL (Old Course) [April / 2015]
[Question Paper] Advanced SQL (Old Course) [April / 2015]
 
Regla de simpson
Regla de simpsonRegla de simpson
Regla de simpson
 

Semelhante a Lecture 1 python arithmetic (ewurc)

1. (5 pts) Which of these graphs represent a one-to-one function .docx
1. (5 pts) Which of these graphs represent a one-to-one function .docx1. (5 pts) Which of these graphs represent a one-to-one function .docx
1. (5 pts) Which of these graphs represent a one-to-one function .docxlindorffgarrik
 
Notes and formulae mathematics
Notes and formulae mathematicsNotes and formulae mathematics
Notes and formulae mathematicsZainonie Ma'arof
 
tutorial5.ppt
tutorial5.ppttutorial5.ppt
tutorial5.pptjvjfvvoa
 
logarithmic, exponential, trigonometric functions and their graphs.ppt
logarithmic, exponential, trigonometric functions and their graphs.pptlogarithmic, exponential, trigonometric functions and their graphs.ppt
logarithmic, exponential, trigonometric functions and their graphs.pptYohannesAndualem1
 
Some hours of python
Some hours of pythonSome hours of python
Some hours of pythonThings Lab
 
Notes and Formulae Mathematics SPM
Notes and Formulae Mathematics SPM Notes and Formulae Mathematics SPM
Notes and Formulae Mathematics SPM Zhang Ewe
 
Notes and-formulae-mathematics
Notes and-formulae-mathematicsNotes and-formulae-mathematics
Notes and-formulae-mathematicsAh Ching
 
M166Calculus” ProjectDue Wednesday, December 9, 2015PROJ.docx
M166Calculus” ProjectDue Wednesday, December 9, 2015PROJ.docxM166Calculus” ProjectDue Wednesday, December 9, 2015PROJ.docx
M166Calculus” ProjectDue Wednesday, December 9, 2015PROJ.docxinfantsuk
 
Basic python programs
Basic python programsBasic python programs
Basic python programsRaginiJain21
 
Chapter 1 Basic Programming (Python Programming Lecture)
Chapter 1 Basic Programming (Python Programming Lecture)Chapter 1 Basic Programming (Python Programming Lecture)
Chapter 1 Basic Programming (Python Programming Lecture)IoT Code Lab
 
#3 Exam Helper - Knowledge Booster (for Government Job) 3 rd Edition
#3 Exam Helper - Knowledge Booster (for Government Job) 3 rd Edition#3 Exam Helper - Knowledge Booster (for Government Job) 3 rd Edition
#3 Exam Helper - Knowledge Booster (for Government Job) 3 rd EditionExam Affairs!
 
Python programming workshop session 3
Python programming workshop session 3Python programming workshop session 3
Python programming workshop session 3Abdul Haseeb
 
CS330-Lectures Statistics And Probability
CS330-Lectures Statistics And ProbabilityCS330-Lectures Statistics And Probability
CS330-Lectures Statistics And Probabilitybryan111472
 

Semelhante a Lecture 1 python arithmetic (ewurc) (20)

1. (5 pts) Which of these graphs represent a one-to-one function .docx
1. (5 pts) Which of these graphs represent a one-to-one function .docx1. (5 pts) Which of these graphs represent a one-to-one function .docx
1. (5 pts) Which of these graphs represent a one-to-one function .docx
 
Notes and formulae mathematics
Notes and formulae mathematicsNotes and formulae mathematics
Notes and formulae mathematics
 
tutorial5.ppt
tutorial5.ppttutorial5.ppt
tutorial5.ppt
 
M112rev
M112revM112rev
M112rev
 
logarithmic, exponential, trigonometric functions and their graphs.ppt
logarithmic, exponential, trigonometric functions and their graphs.pptlogarithmic, exponential, trigonometric functions and their graphs.ppt
logarithmic, exponential, trigonometric functions and their graphs.ppt
 
Some hours of python
Some hours of pythonSome hours of python
Some hours of python
 
Notes and Formulae Mathematics SPM
Notes and Formulae Mathematics SPM Notes and Formulae Mathematics SPM
Notes and Formulae Mathematics SPM
 
Notes and-formulae-mathematics
Notes and-formulae-mathematicsNotes and-formulae-mathematics
Notes and-formulae-mathematics
 
Mathematics formulas
Mathematics formulasMathematics formulas
Mathematics formulas
 
Rumus matematik examonline spa
Rumus matematik examonline spaRumus matematik examonline spa
Rumus matematik examonline spa
 
M166Calculus” ProjectDue Wednesday, December 9, 2015PROJ.docx
M166Calculus” ProjectDue Wednesday, December 9, 2015PROJ.docxM166Calculus” ProjectDue Wednesday, December 9, 2015PROJ.docx
M166Calculus” ProjectDue Wednesday, December 9, 2015PROJ.docx
 
Basic python programs
Basic python programsBasic python programs
Basic python programs
 
Chapter 1 Basic Programming (Python Programming Lecture)
Chapter 1 Basic Programming (Python Programming Lecture)Chapter 1 Basic Programming (Python Programming Lecture)
Chapter 1 Basic Programming (Python Programming Lecture)
 
Hprec7 4
Hprec7 4Hprec7 4
Hprec7 4
 
#3 Exam Helper - Knowledge Booster (for Government Job) 3 rd Edition
#3 Exam Helper - Knowledge Booster (for Government Job) 3 rd Edition#3 Exam Helper - Knowledge Booster (for Government Job) 3 rd Edition
#3 Exam Helper - Knowledge Booster (for Government Job) 3 rd Edition
 
U 2-bm-2
U 2-bm-2U 2-bm-2
U 2-bm-2
 
Python programming workshop session 3
Python programming workshop session 3Python programming workshop session 3
Python programming workshop session 3
 
Introduction to c part 2
Introduction to c   part  2Introduction to c   part  2
Introduction to c part 2
 
Math 116 pres. 5
Math 116 pres. 5Math 116 pres. 5
Math 116 pres. 5
 
CS330-Lectures Statistics And Probability
CS330-Lectures Statistics And ProbabilityCS330-Lectures Statistics And Probability
CS330-Lectures Statistics And Probability
 

Mais de Al-Mamun Riyadh (Mun)

Mais de Al-Mamun Riyadh (Mun) (8)

Prime Number (Sieve)
Prime Number (Sieve)Prime Number (Sieve)
Prime Number (Sieve)
 
Workshop on arduino (ewurc)
Workshop on arduino (ewurc)Workshop on arduino (ewurc)
Workshop on arduino (ewurc)
 
Lecture 6 python oop (ewurc)
Lecture 6 python oop (ewurc)Lecture 6 python oop (ewurc)
Lecture 6 python oop (ewurc)
 
Lecture 5 python function (ewurc)
Lecture 5 python function (ewurc)Lecture 5 python function (ewurc)
Lecture 5 python function (ewurc)
 
Lecture 4 python string (ewurc)
Lecture 4 python string (ewurc)Lecture 4 python string (ewurc)
Lecture 4 python string (ewurc)
 
Lecture 3.1 python loop 1 (ewurc)
Lecture 3.1 python loop 1 (ewurc)Lecture 3.1 python loop 1 (ewurc)
Lecture 3.1 python loop 1 (ewurc)
 
Lecture 2 python conditional (ewurc)
Lecture 2 python conditional (ewurc)Lecture 2 python conditional (ewurc)
Lecture 2 python conditional (ewurc)
 
Lecture 0 python basic (ewurc)
Lecture 0 python basic (ewurc)Lecture 0 python basic (ewurc)
Lecture 0 python basic (ewurc)
 

Último

Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701bronxfugly43
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxEsquimalt MFRC
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxcallscotland1987
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024Elizabeth Walsh
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structuredhanjurrannsibayan2
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfSherif Taha
 

Último (20)

Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 

Lecture 1 python arithmetic (ewurc)

  • 1.
  • 3. Topic • Arithmetic Operation • Operator (Arithmetic Operator) • More Built in Function • Module (Math) • Problem Set 1: Arithmetic (15)
  • 4. Summation of two number. a = int(input()) b = int(input()) sum = a + b print(sum)
  • 5. Difference of two number. a = int(input()) b = int(input()) diff = a - b print(diff)
  • 6. Product of two number. a = int(input()) b = int(input()) pro = a * b print(pro)
  • 7. Quotient of two number. a = int(input()) b = int(input()) quo = a / b print(quo)
  • 8. Reminder of two number. a = int(input()) b = int(input()) rem = a % b print(rem)
  • 9. Find Exponent (a^b). [1] a = int(input()) b = int(input()) ## Exponent with Arithmetic Operator ## Syntax: base ** exponent exp = a ** b print(exp)
  • 10. 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)
  • 11. 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)
  • 12. Find Exponent (a^b). [4] a = int(input()) b = int(input()) # Using Math Library import math exp = math.pow(a,b) print(exp)
  • 13. Floor Division. a = int(input()) b = int(input()) div = a // b print(div) a = float(input()) b = float(input()) div = a // b print(div)
  • 14. Find absolute difference of two number. [1] a = int(input()) b = int(input()) absdif = abs(a - b) print(absdif)
  • 15. Find absolute difference of two number. [2] import math a = float(input()) b = float(input()) absdif = math.fabs(a - b) print(absdif)
  • 16. Average of three numbers. a = float(input()) b = float(input()) c = float(input()) sum = a + b + c avg = sum/3 print(avg)
  • 17. Area of Triangle using Base and Height. b = float(input()) h = float(input()) area = (1/2) * b * h print(area)
  • 18. 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)
  • 19. Area of Circle using Radius. import math r = float(input()) pi = math.pi area = pi * r**2 # area = pi * pow(r,2) print(area)
  • 20. Convert Temperature Celsius to Fahrenheit. # (C/5) = (F-32)/9 celsius = float(input()) fahrenheit = 9 * (celsius/5) + 32 print(fahrenheit)
  • 21. Convert Temperature Fahrenheit to Celsius. # (C/5) = (F-32)/9 fahrenheit = float(input()) celsius = (fahrenheit-32)/9 * 5 print(celsius)
  • 22. Convert Second to HH:MM:SS. # 1 Hour = 60 Minutes # 1 Minute = 60 Seconds totalSec = int(input()) hour = int(totalSec/3600) remSec = int(totalSec%3600) minute = int(remSec/60) second = int(totalSec%60) print("{}H {}M {}S".format(hour,minute,second)) #print(f"{hour}H {minute}M {second}S") # 1 Hour = 60 Minutes # 1 Minute = 60 Seconds totalSec = int(input()) hour = totalSec//3600 remSec = totalSec%3600 minute = remSec//60 second = totalSec%60 print("{}H {}M {}S".format(hour,minute,second)) #print(f"{hour}H {minute}M {second}S")
  • 23. Built-in Function • abs(x) • pow(x,y) • https://docs.python.org/3.6/library/functions.html
  • 24. Math Module • math.pow(x, y) • math.sqrt(x) • math.pi • https://docs.python.org/3.6/library/math.html
  • 25. Problem Set 1: Arithmetic (15) • Summation of two number. • Difference of two number. • Product of two number. • Quotient of two number. • Reminder of two number. • Find Exponent (a^b). • Floor Division. • Find absolute difference of two number. • Average of three numbers. • Area of Triangle using Base and Height. • Area of Triangle using Length of 3 sides. • Area of Circle using Radius. • Convert Temperature Celsius to Fahrenheit. • Convert Temperature Fahrenheit to Celsius. • Convert Second to HH:MM:SS.
  • 27. Prepared by Mun Al Mamun President East West University Robotics Club munewu@gmail.com T h i s s l i d e i s p r o v i d e a s a c o u r s e m a t e r i a l i n t h e w o r k s h o p “ W o r k s h o p O n P y t h o n P r o g r a m m i n g ” O r g a n i z e d b y E a s t W e s t U n i v e r s i t y R o b o t i c s C l u b