Skip to content

Ilm o Irfan

Technologies

  • Home
  • Courses
    • Free Courses
  • Motivational Seminars
  • Blog
  • Books
  • Contact
Menu
  • Home
  • Courses
    • Free Courses
  • Motivational Seminars
  • Blog
  • Books
  • Contact
Search
Close this search box.
Explore Courses

Introduction to Python

  • September 1, 2022
  • No Comments
  • Home
  • Free Book

Table of Contents

Chapter 7 - Operators and Expressions

  • Authors
  • Ms. Samavi Salman
  • Dr. Rao Muhammad Adeel Nawab
  • Supporting Material
  • Download Supporting Material (Code): here

Quick Recap

  • Quick Recap – Variables in Python

In previous Chapter, I presented the following main concepts:

          •  
  • Variable
    • A Variable is defined as the Name Assigned to a Memory Location / Memory Address (to store Data (Values / Constants)), that can change (i.e., does not remain the same) every time a Python Program is executed
  • Three main Components of a Variable are
    • Variable Name
    • Value (stored) in a Variable (i.e., Content of a Variable)
    • Memory Location / Memory Address (used to store Value of a Variable)
  • Main Operations on a Variable
    • The main Operations performed on a Variable are
  • Operation 01
    • Store Value in a Variable
  • Operation 02
    • Modify / Update Value of a Variable
  • Operation 03
    • Use Value of a Variable for various Tasks
  • In Python, there are three main Types of Variables
    • Integer Variables
    • Float Variables
    • String Variables
  • Integer Variable
    • An Integer Variable is defined as the Name Assigned to a Memory Location / Memory Address (to store Integer Values (Constants)), that can change (i.e., does not remain the same) every time a Python Program is executed
  • Float Variable
    • A Float Variable is defined as the Name Assigned to a Memory Location / Memory Address (to store Floating-Point Values (Constants)), that can change (i.e., does not remain the same) every time a Python Program is executed
  • String Variable
    • A String Variable is defined as the Name Assigned to a Memory Location / Memory Address (to store Fixed Sequence of Characters (Constants)), that can change (i.e., does not remain the same) every time a Python Program is executed
  • input () Function
    • The input() Function takes User input (reads a Line) convert it in a String and return it
  • Code Time Variable Value vs Run Time Variable Value
    • Code Time Variable Value
      • At Code Time, the Value to be stored in a Variable is
        • Decided by the Programmer
    • Run Time Variable Value
      • At Run Time, the Value to be stored in a Variable is
        • Decided by the User (of the Program / Software)
  • Dry Run
    • The testing process which reduces the effect of Failure is called Dry Run
      • Check Data Type of Variable using type() Function
      • Check Memory Address of a Variable using id() Function
  • Variable Naming Conventions – Best Coding Practices
    • Best Coding Practice 01
      • Variable Name should be in lower case
    • Best Coding Practices 02
      • Use expressive Variable Names
    • Best Coding Practices 03
      • Use underscore to separate words in long Variable Names

Operation, Operator and Operand

  • Operation
  • Definition
    • In Computer Programming, an Operation is defined as an action that is carried out to accomplish a given Task
  • Purpose
    • The main purpose of an Operation is to
      • accomplish a given Task
  • Five Basic Computer Operations
  • The five basic Computer Operations are
    • Input
    • Processing
    • Output
    • Store
    • Control
  • Performing Various Operations in a Computer
  • Question
    • Who performs various Operations in a Computer?
  • Answer
    • Processors (a.k.a. CPU (Central Processing Unit))
  • Performing Complex Tasks using Computers
  • Question
    • How CPUs perform complex Tasks?
  • Answer
    • CPUs perform complex Tasks by executing thousands of individual Operations per Second
  • Main Types of Operations
  • Question
    • What are main Types of Operations performed by a CPU?
  • Answer
    • CPU performs two main Types of Operations
      • Arithmetic Operations
      • Logical Operations
  • Unit of CPU Performing Arithmetic and Logical Operations
  • Question
    • Which Unit of CPU performs Arithmetic and Logical Operations?
  • Answer
    • Arithmetic-Logic Unit (ALU)
  • Operator
  • Definition
    • In Computer Programming, an Operator is defined as a special Symbol, which is used to carry out Arithmetic / Logical Operations
  • Purpose
    • The main purpose of Operators is to
      • Carry out different Operations to accomplish a given Task
  • Importance
    • To perform a given Task, we need to perform various Operations
    • Without Operators, we cannot perform Operations
  • Applications
    • Operators are used to perform
      • Arithmetic and Logical Operations to perform various useful Tasks
  • Operand
  • In Computer Programming, an Operand is defined as the Object (or Value) on which an Operator operates

Expression

  • Expression
  • Definition
    • In Programming Language, an Expression is a combination of Operands (Variables / Constants) and Operator(s) to produce an Output Value
  • Note
    • An Expression is a Python Statement which returns a Value
  • Purpose
    • The main purpose of an Expression is to perform various Operations to
      • accomplish a given Task
  • Importance
    • Expressions help us to perform
      • Complex Calculations and Tasks
  • Main Components of an Expression
  • An Expression comprises of Two Main Components
    • Operator
    • Operands
  • Note
    • In an Expression, we must have at least
      • One Operator and
      • Two Operands
    • In an Expression, Operands can be either
      • Variables or
      • Constants
  • Valid Expressions vs Invalid Expressions

For an Expression to be Valid, it must satisfy the following Conditions

Conditions for a Valid Expressions

  • Condition 01
    • A Valid Expression will have at least
      • One Operator and
      • Two Operands
  • Condition 02
    • Operands in an Expression should be either
      • Variables or
      • Constants
  • Condition 03
    • When a Variable is used in an Expression, it must be
      • first declared and Value must be Stored in it before using it in an Expression
    • Note
      • If we use a Variable without Declaration and Storing a Value in it
      • An Error will be generated, and Python Program will not be executed
  • Condition 04
    • Since an Expression returns an Output Value, we may use an Expression in either
      • print() Statement or
      • Assignment Statement
    • Note
      • If we don’t use the Result (Output Value) returned by an Expression in either: (1) print() Statement – to display Output Value on the Output Screen, or (2) Store it in a Variable using Assignment Statement – for further processing
      • An Error will be generated, and Python Program will not be executed
  • Condition 05
    • If an Expression is used in an Assignment Statement, then
      • We must have a Variable on Left Hand Side (LHS) of the Assignment Statement and
      • Expression should come on the Right-Hand Side (RHS) of the Assignment Statement
    • Note
      • If we do not use a Variable on the LHS of an Assignment Statement
      • An Error will be generated, and Python Program will not be executed
  • Valid Expressions vs Invalid Expressions Cont…
Task Description
  • Task Description
    • Consider the following Python Program and answer the questions given below
      • Questions 
        • Identify Expression(s) in the given Python Program? 
        • Classify the Expressions identified in the first Question as either: (1) Valid Expression or (2) Invalid Expression?
      • Note 
        • Your answers should be 
          • Well Justified
    • Python Program
    •  
				
					print("5 + 2 = ",  5 + 2)
number1 = 10 - 7
number2 = number1 + 10
print("Square of number1 is = " , number1 * number1)
number2 + number1
				
			
Expressions in Python Program
  • The above Python Program contains five Expressions
    • Expression 01
      • 5 + 2
    • Expression 02
      • 10 – 7
    • Expression 03
      • number + 10
    • Expression 04
      • number * number
    • Expression 05
      • number2 + number1
  • Example 1 – Valid Expressions vs Invalid Expressions Cont…
Checking Validity of Expression 01
  • Python Statement
    • print(“5 + 2 = “,  5 + 2)
  • Expression 01 (used in print() Statement)
    • Expression 01 is
      • 5 + 2
Analysis of Expression
  • Analyze Expression 01
    • Operators in Expression 01
      • Operator 01 
        • +
    • Operands in Expression 01
      • Operand 01
        • 5
      • Operand 02
        • 2
    • Expression (5 + 2) is used in print() Statement 
      • Therefore, the Result (Output Value) produced by the Expression will be displayed on the Output Screen
Summary – Analysis of Expression 01
  • In Expression 01
    • Operator is
      • Arithmetic Operator
    • Both Operands are
      • Constants
  • Result (Output Value) produced by the Expression will be displayed on the Output Screen using print() Function
Main Findings
  • Finding 01
    • Expression 01 satisfies 
      • Condition 01, Condition 02 and Condition 04
Conclusion
  • Expression 01 is a 
    • Valid Expression
Reason – Why Expression 01 is a Valid Expressions
  • Expression 01 satisfies 
    • Condition 01, Condition 02 and Condition 04
  • Example 2 – Valid Expressions vs Invalid Expressions Cont…
Checking Validity of Expression 02
  • Python Statement 
    • number1 = 10 – 7
  • Expression 02 (used in Python Statement)
    • Expression 02 is
      • 10 – 7
Analysis of Expression
  • Analyze Expression 02
    • Operators in Expression 02
      • Operator 01
        • –
    • Operands in Expression 02
      • Operand 01
        • 10
      • Operand 01
        • 7
    • Expression 10 – 7 is used in Assignment Statement 
      • Therefore, the Result (Output Value) produced by the Expression will be stored in Variable (number1)
Summary – Analysis of Expression 02
  • In Expression 02
    • Operator is
      • Arithmetic Operator
    • Both Operands are
      • Constants
  • Result (Output Value) produced by the Expression will be stored in Variable (number1)
Main Findings
  • Finding 01
    • Expression 02 satisfies 
      • Condition 01, Condition 02, Condition 04 and Condition 05
Conclusion
  • Expression 02 is a 
    • Valid Expression
Reason – Why Expression 02 is a Valid Expressions
  • Expression 02 satisfies 
    • Condition 01, Condition 02, Condition 04 and Condition 05
  • Example 3 – Valid Expressions vs Invalid Expressions Cont…
Checking Validity of Expression 03
  • Python Statement 
    • Number2 = number1 + 10
  • Expression 03 (used in Python Statement)
    • Expression 03 is
      • number1 + 10
Analysis of Expression
  • Analyze Expression 03
    • Operators in Expression 03
      • Operator 01
        • +
    • Operands in Expression 03
      • Operand 01
        • Variable (i.e. number1)
      • Operand 02
        • Constant (i.e., 10)
    • Expression number1 + 10 is used in Assignment Statement 
      • Therefore, the Result (Output Value) produced by the Expression will be stored in Variable (number2)
Summary – Analysis of Expression 03
  • In Expression 03
    • Operator is
      • Arithmetic Operator
    • Operands 
      • Operand 01 is a Variable
      • Operand 02 is a Constant
    • Result (Output Value) produced by the Expression will be stored in Variable (number2) 
Main Findings
  • Finding 01
    • Expression 03 satisfies 
      • Condition 01, Condition 02, Condition 03, Condition 04 and Condition 05
Conclusion
  • Expression 03 is a 
    • Valid Expression 
Reason – Why Expression 03 is a Valid Expression
  • Expression 03 satisfies 
    • Condition 01, Condition 02, Condition 03, Condition 04 and Condition 05
  • Example 4 – Valid Expressions vs Invalid Expressions Cont…
Checking Validity of Expression 04
  • Python Statement 
    • print(“Square of number1 is = ” , number1 * number1)
  • Expression 04 (used in Python Statement)
    • Expression 04 is
      • number1 * number1
Analysis of Expression
  • Analyze Expression 04
    • Operators in Expression 04
      • Operator 04
        • *
      • Operands in Expression 04
        • Operand 01
          • Variable (i.e., number1)
        • Operand 02
          • Variable (i.e., number2)
    • Expression number1 * number2 is used in print() Statement
      • Therefore, the Result (Output Value) produced by the Expression will be displayed on the Output Screen
Summary – Analysis of Expression 04
  • In Expression 04
    • Operator is
      • Arithmetic Operator
    • Both Operands are
      • Variables
    • Result (Output Value) produced by the Expression will be displayed on the Output Screen using print() Function  
Main Findings
  • Finding 01
    • Expression 04 satisfies
      • Condition 01, Condition 02, Condition 04 and Condition 05
Conclusion
  • Expression 04 is a 
    • Valid Expression 
Reason – Why Expression 04 is a Valid Expression
  • Expression 04 satisfies
    • Condition 01, Condition 02, Condition 04 and Condition 05
  • Example 5 – Valid Expressions vs Invalid Expressions Cont…

 

Checking Validity of Expression 05
  • Python Statement 
    • number2 + number1
  • Expression 05 (used in Python Statement)
    • Expression 05 is
      • number2 + number1
Analysis of Expression
  • Analyze Expression 05
    • Operators in Expression 05
      • Operator 01
        • +
    • Operands in Expression 05
      • Operand 01
        • Variable (i.e., number2)
      • Operand 02
        • Variable (i.e., number1)
    • Expression number2 + number1 is not used in Assignment Statement or Print Statement
      • Therefore, the Result (Output Value) produced by the Expression will not be stored / displayed
Summary – Analysis of Expression 05
  • In Expression 05
    • Operator is
      • Arithmetic Operator
    • Both Operands are
      • Variables
    • Result (Output Value) produced by the Expression will not be stored / displayed
Main Findings
  • Finding 01
    • Expression 05 does not satisfy 
      • Condition 04 and Condition 05
Conclusion
  • Expression 05 is an 
    • Invalid Expression
Reason – Why Expression 05 is a Valid Expression
  • Expression 05 does not satisfy
    • Condition 04 and Condition 05

TODO and Your Turn

Todo Tasks
Your Turn Tasks
Todo Tasks

TODO Task 1

  • Task 
    • Consider the following Python Program and answer the questions given below
  • Python Statements
    • print(“5 ** 2 = “,  5 ** 2)
    • number1 = 36 – 46
    • number2 = number1 * 50
    • print(“Cube of number1 is = ” , number1 * number1 * number1)
    • number2 % number1
  • Note 
    • Your answer should be 
      • Well Justified
  • Questions
    • Identify Expressions in above Python Program?
    • Classify each Expression as either Valid Expression or Invalid Expression using the following Template
      • Checking Validity of Expression 
      • Analyze the Expression
        • Operands
        • Operators
    • Summary – Analysis of Expression
    • Main Findings
    • Conclusion
    • Reason – Why Expression is Valid / Invalid 
Your Turn Tasks

Your Turn Task 1

  • Task
    • Write a Python Program (like the one given in the TODO Task) and answer the questions given below 
  • Note 
    • Your answer should be 
      • Well Justified
  • Questions
    • Identify Expressions in your Python Program?
    • Classify each Expression as either Valid Expression or Invalid Expression using the following Template
      • Checking Validity of Expression 
      • Analyze the Expression
        • Operands
        • Operators
    • Summary – Analysis of Expression
    • Main Findings
    • Conclusion
    • Reason – Why Expression is Valid / Invalid

Arithmetic Operators

  • Three Main Components of a Variable

Types of Operators

  • The main Types of Operators (in Python) are
    • Assignment Operator
    • Arithmetic Operators
    • Logical Operators
    • Comparison Operators
    • Membership Operators
    • Identity Operators
  • Three Main Components of a Variable

Chapter Focus

  • The focus of this Chapter is on
    • Arithmetic Operators

Assignment Operator

  • Assignment Operator
  • Definition
    • Assignment Operator is represented with = Symbol 
  • Purpose
    • The main purpose of an Assignment Operator is to
      • Store Value in a Variable 
  • Importance 
    • To perform various Operations on a Variable, 
      • We must first store value in that Variable using Assignment Operator 
  • Applications
    • Assignment Operator is used to
      • Store Value in a Variable
      • Modify / Update Value of a Variable

Arithmetic Operator

  • Arithmetic Operator
  • Definition
    • An Arithmetic Operator is an Operator that takes two Operands and performs Calculation on them
  • Purpose
    • The main purpose of Arithmetic Operators is to 
      • Perform various Arithmetic Calculations like addition, subtraction, division, multiplication etc.
  • Importance
    • Arithmetic Operators are used to perform various Arithmetic Calculations, which help us to accomplish complex Tasks
  • Applicators
    • Arithmetic Operators are useful to carry out
      • Arithmetic Calculations
  • Types of Arithmetic Operators in Python
  • In Python, we have following six Arithmetic Operators 
    • Addition 
      • +
    • Subtraction 
      • –
    • Multiplication 
      • *
    • Division 
      • /
    • Exponent 
      • **
    • Modulus  
      • %

Addition Operator

  • Assignment Operator
  • Symbol
    • +
  • Purpose 
    • Add Two Values
  • + Operator Usage in an Expression 
    • Operand 01 + Operand 02
  • How + Operator Works 
    • Adds Operand 01 and Operand 02 and 
      • returns a Single Output Value
  • Example 1 - Addition Operator
Completely and Correctly Understand the Task
Task Description
  • What Output Value will be returned by the Expression given in the following Python Program?
    • Python Statement
      • number1 = 7 + 10
    • Expression
      • 7 + 10
  • In above Expression
    • Operator
      • +
    • Operand 01
      • 7 (Constant)
    • Operand 02
      • 10 (Constant)
Plan and Design Solution to the Task
Input-Processing-Output
  • Input
    • Data
      • An Expression
    • Instruction(s)
      • Perform Arithmetic Operation(s) by applying Arithmetic Operators on the Operands given in the Expression
  • Output
    • A Single Value (obtained by performing Arithmetic Operation(s))
  • Processing
    • Step  1: Perform Arithmetic Operation(s) – Apply Arithmetic Operator (+) on the Operands given in the Expression
    • Step  2: Store Result (Output Value) returned by Expression in Variable (number1)
Output – Returned by Expression
17
Reason – Why Expression Returned Output Value of 17
  • Calculating Expression
    • 7 + 10
      •  17
Analysis, Main Findings and Conclusions
Analysis
  • In above Expression
    • Operator is
      • +
    • Operand 01 is
      • A Constant (i.e., 7)
    • Operand 02 is
      • A Constant (i.e., 10)
  • Analysis
    • In this Expression
      • We performed a Simple Arithmetic Operation i.e., Calculated the Sum of Two Integer Constants and
      • Stored Result (Output Value) returned by Expression in Variable (number1)
Main Findings
  • Finding 01
    • When we use Constants in an Expression
      • Constants (Values) are used in performing Arithmetic Operations (Calculations)
  • Finding 02
    • When we use Expression in an Assignment Statement
      • Result (Output Value) produced by the Expression (on RHS of Assignment Statement) is Stored in Variable (on the LHS of Assignment Statement)
  • Finding 03
    • An Expression returns only a Single Output Value
  • Finding 04
    • We can use Expressions to perform various useful Real-world Tasks
Conclusions
  • Expressions help us to perform Arithmetic Operations (Calculations) to accomplish various Real-world Tasks  
  • Example 2 - Addition Operator
Completely and Correctly Understand the Task
Task Description
  • What Output Value will be returned by the Expression given in the following Python Program?
    • Python Statement
      • number1 = 10
      • number2 = number1 + 5
    • Expression
      • number1 + 5
  • In above Expression
    • Operator
      • +
    • Operand 01
      • number1 (Variable)
    • Operand 02
      • 5 (Constant)
Plan and Design Solution to the Task
Input-Processing-Output
  • Input
    • Data
      • An Expression
    • Instruction(s)
      • Perform Arithmetic Operation(s) by applying Arithmetic Operators on the Operands given in the Expression
    • Output
      • A Single Value (obtained by performing Arithmetic Operation(s))
    • Processing
      • Step 1: Perform Arithmetic Operation(s) – Apply Arithmetic Operator (+) on the Operands given in the Expression
      • Step 2: Store Result (Output Value) returned by Expression in Variable (number2)
Output – Returned by Expression
15
Reason – Why Expression Returned Output Value of 15
  • Value of Variable (number1) is 10
    • Calculating Expression
      • number1 + 5
      • 10 + 5
      • 15
Analysis, Main Findings and Conclusions
Analysis
  • In above Expression
    • Operator is
      • +
    • Operand 01 is
      • A Variable (i.e., 10)
    • Operand 02 is
      • A Constant (i.e., 5)
  • Analysis
    • In this Expression
      • We performed a Simple Arithmetic Operation i.e., Calculated the Sum of Two Integers (One Variable and One Constant) and
      • Stored Result (Output Value) returned by Expression in Variable (number2)
Main Findings
  • Finding 01
    • When we use Variables in an Expression
      • Values of Variables are used in performing Arithmetic Operations (Calculations)
  • Finding 02
    • When we use Constants in an Expression
      • Constants (Values) are used in performing Arithmetic Operations (Calculations)
  • Finding 03
    • An Expression returns only a Single Output Value
  • Finding 04
    • We can use Expressions to perform various useful Real-world Tasks
Conclusions
  • Expressions help us to perform Arithmetic Operations (Calculations) to accomplish various Real-world Tasks  
  • Example 3 - Addition Operator
Completely and Correctly Understand the Task
Task Description
  • What Output Value will be returned by the Expression given in the following Python Program?
    • Python Statament
      • number1 = 3.8
      • number2 = 1.4
      • number3 = number1 + number2
    • Expression
      • number1 + number2
  • In above Expression
    • Operator
      • +
    • Operand 01
      • number1 (Variable)
    • Operand 02
      • number2 (Variable)
Plan and Design Solution to the Task
Input-Processing-Output
  • Input
    • Data
      • An Expression
    • Instruction(s)
      • Perform Arithmetic Operation(s) by applying Arithmetic Operators on the Operands given in the Expression
  • Output
    • A Single Value (obtained by performing Arithmetic Operation(s)) 
  • Processing
    • Step  1: Perform Arithmetic Operation(s) – Apply Arithmetic Operator (+) on the Operands given in the Expression
    • Step  2: Store Result (Output Value) returned by Expression in Variable (number3)
Output – Returned by Expression
5.2
Reason – Why Expression Returned Output Value of 5.2
  • Value of Variable (number1) is 3.8
  • Value of Variable (number2) is 1.4
  • Calculating Expression 
    • number1 + number2
    • 3.8 + 1.4
    • 5.2
Analysis, Main Findings and Conclusions
Analysis
  • In above Expression 
    • Operator is 
      • +
    • Operand 01 is
      • A Variable (i.e., 3.8)
    • Operand 02 is
      • A Variable (i.e., 1.4)
  • Analysis
    • In this Expression
      • We performed a Simple Arithmetic Operation i.e., Calculated the Sum of Two Float Variables and 
      • Stored Result (Output Value) returned by Expression in Variable (number3)
Main Findings
  • Finding 01
    • When we use Variables in an Expression 
      • Values of Variables are used in performing Arithmetic Operations (Calculations)
  • Finding 02
    • An Expression returns only a Single Output Value 
  • Finding 03
    • We can use Expressions to perform various useful Real-world Tasks
Conclusions
  • Expressions help us to perform Arithmetic Operations (Calculations) to accomplish various Real-world Tasks  

 

  • Comparing Example 1 vs Example 2 vs Example 3
Example 1 – Expression is 7 + 10
  • In Example 1 – Expression is 7 + 10
    • Both Operands are Integer Constants 
      • Operand 01
        • 7
      • Operand 02
        • 10
    • Output Value – Returned by Expression is an Integer Constant
      • 17
Example 2 – Expression is number1 + 5
  • In Example 2 – Expression is number1 + 5
    • First Operand is an Integer Variable and Second Operand is an Integer Constant 
    • Operand 01
      • number1
    • Operand 02
      • 5
  • Output Value – Returned by Expression is an Integer Constant
    • 15
Example 3 – Expression is number1 + number2
  • In Example 3 – Expression is number1 + number2
    • First Operand is a Float Variable and Second Operand is also a Float Variable 
      • Operand 01
        • number1
      • Operand 02
        • number2
    • Output Value – Returned by Expression is a Float Constant
      • 5.2
Analysis
  • Analysis and Main Finding 
    • Finding 01
      • In all three Examples (Example 1, Example 2 and Example 3), Expression either returned an
        • Integer Value (Constant) or 
      • Float Value (Constant)
Conclusion
  • These Examples indicate that Expression always returns an 
    • Output Value 

Subtraction Operator

  • Subtraction Operator
  • Symbol
    • –
  • Purpose 
    • Subtract One Value from another Value 
  • – Operator Usage in an Expression 
    • Operand 01 – Operand 02
  • How – Operator Works 
    • Subtracts Operand 02 from Operand 01 and 
      • returns a Single Output Value 
  • Example 1 - Subtraction Operator
Completely and Correctly Understand the Task
Task Description
  • What Output Value will be returned by the Expression given in the following Python Program?
    • Python Statement
      • number1 = 10 – 7
    • Expression
      • 10 – 7
  • In above Expression
    • Operator
      • –
    • Operand 01
      • 10 (Constant)
    • Operand 02
      • 7 (Constant)
Plan and Design Solution to the Task
Input-Processing-Output
  • Input
    • Data
      • An Expression
    • Instruction(s)
      • Perform Arithmetic Operation(s) by applying Arithmetic Operators on the Operands given in the Expression
  • Output
    • A Single Value (obtained by performing Arithmetic Operation(s)) 
  • Processing
    • Step  1: Perform Arithmetic Operation(s) – Apply Arithmetic Operator (-) on the Operands given in the Expression
    • Step  2: Store Result (Output Value) returned by Expression in Variable (number1)
Output – Returned by Expression
3
Reason – Why Expression Returned Output Value of 3
  • Calculating Expression 
    • 10 – 7
    • 3
Analysis, Main Findings and Conclusions
Analysis
  • In above Expression
    • Operator is 
      • –
    • Operand 01 is
      • A Constant (i.e., 10)
    • Operand 02 is
      • A Constant (i.e., 7)
  • Analysis 
    • In this Expression, we performed a Simple Arithmetic Operation i.e., Calculated the Subtraction of Two Integer Constants
Main Findings
  • Finding 01
    • When we use Constants in an Expression 
      • Constants (Values) are used in performing Arithmetic Operations (Calculations)
  • Finding 02
    • An Expression returns only a Single Output Value 
  • Finding 03
    • We can use Expressions to perform various useful Real-world Tasks
Conclusions
  • Expressions help us to perform Arithmetic Operations (Calculations) to accomplish various Real-world Tasks  
  • Example 2 - Subtraction Operator

 

Completely and Correctly Understand the Task
Task Description
  • What Output Value will be returned by the Expression given in the following Python Program?
    • Python Statement
      • number1 = 5
      • number2 = number1 – 10
    • Expression
      • number1 – 10
  • In above Expression
    • Operator
      • –
    • Operand 01
      • number1 (Variable)
    • Operand 02
      • 10 (Constant)
Plan and Design Solution to the Task
Input-Processing-Output
  • Input
    • Data
      • An Expression
    • Instruction(s)
      • Perform Arithmetic Operation(s) by applying Arithmetic Operators on the Operands given in the Expression
  • Output
    • A Single Value (obtained by performing Arithmetic Operation(s)) 
  • Processing
    • Step  1: Perform Arithmetic Operation(s) – Apply Arithmetic Operator (-) on the Operands given in the Expression
    • Step  2: Store Result (Output Value) returned by Expression in Variable (number2)
Output – Returned by Expression
-5
Reason – Why Expression Returned Output Value of -5
  • Value of Variable (number1) is 5
    • Calculating Expression 
      • number1 – 10
      • 5 – 10 
      • -5
Analysis, Main Findings and Conclusions
Analysis
  • In above Expression
    • Operator is 
      • –
    • Operand 01 is
      • A Variable (i.e., number1)
    • Operand 02 is
      • A Constant (i.e., 10)
  • Analysis 
    • In this Expression, we performed a Simple Arithmetic Operation i.e., Calculated the Subtraction of Two Integers (One Variable and One Constant)
Main Findings
  • Finding 01
    • When we use Variables in an Expression 
      • Values of Variables are used in performing Arithmetic Operations (Calculations)
  • Finding 02
    • When we use Constants in an Expression 
      • Constants (Values) are used in performing Arithmetic Operations (Calculations)
  • Finding 03
    • An Expression returns only a Single Output Value 
  • Finding 04
    • We can use Expressions to perform various useful Real-world Tasks
Conclusions
  • Expressions help us to perform Arithmetic Operations (Calculations) to accomplish various Real-world Tasks  

 

  • Example 3 - Subtraction Operator
Completely and Correctly Understand the Task
Task Description
  • What Output Value will be returned by the Expression given in the following Python Program?
    • Python Statement
      • number1 = 3.8
      • number2 = 1.4
      • number3 = number1 – number2
    • Expression
      • number1 – 10
  • In above Expression
    • Operator
      • –
    • Operand 01
      • number1 (Variable)
    • Operand 02
      • number2 (Variable) 
Plan and Design Solution to the Task
Input-Processing-Output
  • Input
    • Data
      • An Expression
    • Instruction(s)
      • Perform Arithmetic Operation(s) by applying Arithmetic Operators on the Operands given in the Expression
  • Output
    • A Single Value (obtained by performing Arithmetic Operation(s)) 
  • Processing
    • Step  1: Perform Arithmetic Operation(s) – Apply Arithmetic Operator (-) on the Operands given in the Expression
    • Step  2: Store Result (Output Value) returned by Expression in Variable (number2)
Output – Returned by Expression
2.4
Reason – Why Expression Returned Output Value of 2.4
  • Value of Variable (number1) is 3.8
  • Value of Variable (number2) is 1.4
  • Calculating Expression 
    • number1 – number2
    • 3.8 – 1.4
    • 2.4
Analysis, Main Findings and Conclusions
Analysis
  • In above Expression
    •  Operator is 
      • –
    • Operand 01 is
      • A Variable (i.e., number1)
    • Operand 02 is
      • A Variable (i.e., number2)
  • Analysis
    • In this Expression, we performed a Simple Arithmetic Operation i.e., Calculated the Subtraction of Two Float Variables
Main Findings
  • Finding 01
    • When we use Variables in an Expression 
      • Values of Variables are used in performing Arithmetic Operations (Calculations)
  • Finding 02
    • An Expression returns only a Single Output Value 
  • Finding 03
    • We can use Expressions to perform various useful Real-world Tasks
Conclusions
  • Expressions help us to perform Arithmetic Operations (Calculations) to accomplish various Real-world Tasks  

 

  • Comparing Example 1 vs Example 2 vs Example 3
Example 1 – Expression is 10 – 7
  • In Example 1 – Expression is 10 – 7
    • Both Operands are Integer Constants 
      • Operand 01
        • 10
      • Operand 02
        • 7
    • Output Value – Returned by Expression is an Integer Constant
      • 3
Example 2 – Expression is number1 – 10
  • In Example 2 – Expression is number1 – 10
    • First Operand is an Integer Variable and Second Operand is an Integer Constant 
      • Operand 01
        • number1
      • Operand 02
        • 10
    • Output Value – Returned by Expression is an Integer Constant
      • -5
Example 3 – Expression is number1 – number2
  • In Example 3 – Expression is number1 – number2
    • First Operand is a Float Variable and Second Operand is also a Float Variable 
      • Operand 01
        • number1
      • Operand 02
        • number2
    • Output Value – Returned by Expression is a Float Constant
      • 2.4
Analysis
  • Analysis and Main Finding 
    • Finding 01
      • In all three Examples (Example 1, Example 2 and Example 3), Expression either returned an
        • Integer Value (Constant) or 
        • Float Value (Constant)
Conclusion
  • These Examples indicate that Expression always returns an 
    • Output Value 

Multiplication Operator

  • Multiplication Operator
  • Symbol
    • *
  • Purpose 
    • Multiply Two Values 
  • * Operator Usage in an Expression 
    • Operand 01 * Operand 02
  • How * Operator Works 
    • Multiplies Operand 01 with Operand 02 and 
      • returns a Single Output Value 
  • Example 1 - Multiplication Operator
Completely and Correctly Understand the Task
Task Description
  • What Output Value will be returned by the Expression given in the following Python Program?
    • Python Statement
      • number1 = 10 * 7
    • Expression
      • 10 * 7
  • In above Expression
    • Operator
      • *
    • Operand 01
      • 10 (Constant)
    • Operand 02
      • 7 (Constant)
Plan and Design Solution to the Task
Input-Processing-Output
  • Input
    • Data
      • An Expression
    • Instruction(s)
      • Perform Arithmetic Operation(s) by applying Arithmetic Operators on the Operands given in the Expression
  • Output
    • A Single Value (obtained by performing Arithmetic Operation(s)) 
  • Processing
    • Step  1: Perform Arithmetic Operation(s) – Apply Arithmetic Operator (*) on the Operands given in the Expression
    • Step  2: Store Result (Output Value) returned by Expression in Variable (number2)
Output – Returned by Expression
70
Reason – Why Expression Returned Output Value of 70
  • Calculating Expression 
    • 10 * 7
    • 70
Analysis, Main Findings and Conclusions
Analysis
  • In above Expression
    • Operator is 
      • *
    • Operand 01 is
      • A Constant (i.e., 10)
    • Operand 02 is
      • A Constant (i.e., 7)
  • Analysis 
    • In this Expression, we performed a Simple Arithmetic Operation i.e., Calculated the Multiplication of Two Integer Constants
Main Findings
  • Finding 01
    • When we use Constants in an Expression 
      • Constants (Values) are used in performing Arithmetic Operations (Calculations)
  • Finding 02
    • An Expression returns only a Single Output Value 
  • Finding 03
    • We can use Expressions to perform various useful Real-world Tasks
Conclusions
  • Expressions help us to perform Arithmetic Operations (Calculations) to accomplish various Real-world Tasks  
  • Example 2 - Multiplication Operator
Completely and Correctly Understand the Task
Task Description
  • What Output Value will be returned by the Expression given in the following Python Program?
    • Python Statement
      • number1 = 5
      • number2 = number1 * 10
    • Expression
      •  
      • number1 * 10
  • In above Expression
    • Operator
      • *
    • Operand 01
      • number1 (Variable)
    • Operand 02
      • 10 (Constant)
Plan and Design Solution to the Task
Input-Processing-Output
  • Input
    • Data
      • An Expression
    • Instruction(s)
      • Perform Arithmetic Operation(s) by applying Arithmetic Operators on the Operands given in the Expression
  • Output
    • A Single Value (obtained by performing Arithmetic Operation(s)) 
  • Processing
    • Step  1: Perform Arithmetic Operation(s) – Apply Arithmetic Operator (*) on the Operands given in the Expression
    • Step  2: Store Result (Output Value) returned by Expression in Variable (number2)
Output – Returned by Expression
50
Reason – Why Expression Returned Output Value of 50
  • Value of Variable (number1) is 5
  • Calculating Expression 
    • number1 * 10
    • 5 * 10
    • 50
Analysis, Main Findings and Conclusions
Analysis
  • In above Expression
    • Operator is 
      • *
    • Operand 01 is
      • A Variable (i.e., number1)
    • Operand 02 is
      • A Constant (i.e., 10)
  • Analysis 
    • In this Expression, we performed a Simple Arithmetic Operation i.e., Calculated the Multiplication of Two Integers (One Variable and One Constants)
Main Findings
  • Finding 01
    • When we use Variables in an Expression 
      • Values of Variables are used in performing Arithmetic Operations (Calculations)
  • Finding 02
    • When we use Constants in an Expression 
      • Constants (Values) are used in performing Arithmetic Operations (Calculations)
  • Finding 03
    • An Expression returns only a Single Output Value 
  • Finding 04
    • We can use Expressions to perform various useful Real-world Tasks
Conclusions
  • Expressions help us to perform Arithmetic Operations (Calculations) to accomplish various Real-world Tasks  

 

Exponent Operator

  • Exponent
  • Definition 
    • Exponent (or Power) of a Number tells us how many times a Number will be multiplied by itself
  • Example 1
    • 72 = 7 x 7 = 49
    • In above Example 
      • Number = 7
      • Exponent (or Power) = 2
  • Example 2
    • 34 = 3 x 3 x 3 x 3 = 81
    • In above Example 
      • Number = 3
      • Exponent (or Power) = 4
  • Exponent Operator
  • Symbol
    • **
  • Purpose 
    • Take Exponent (Power) of a Number 
  • ** Operator Usage in an Expression 
    • Operand 01 ** Operand 02
  • Note 
    • Operand 01 is a Number and
    • Operand 02 is its Exponent (Power)
  • How ** Operator Works 
    • Operand 01 is multiplied by itself N times (where N is the Value of Operand 02) and 
      • returns a Single Output Value
  • Example 1 - Exponent Operator

 

Completely and Correctly Understand the Task
Task Description
  • What Output Value will be returned by the Expression given in the following Python Program?
    • Python Statement
      • number1 = 2 ** 4
    • Expression
      • 2 ** 4
  • In above Expression
    • Operator
      • **
    • Operand 01
      • 2 (Constant)
    • Operand 02
      • 4 (Constant)
Plan and Design Solution to the Task
Input-Processing-Output
  • Input
    • Data
      • An Expression
    • Instruction(s)
      • Perform Arithmetic Operation(s) by applying Arithmetic Operators on the Operands given in the Expression
  • Output
    • A Single Value (obtained by performing Arithmetic Operation(s)) 
  • Processing
    • Step  1: Perform Arithmetic Operation(s) – Apply Arithmetic Operator (**) on the Operands given in the Expression
    • Step  2: Store Result (Output Value) returned by Expression in Variable (number1)
Output – Returned by Expression
16
Reason – Why Expression Returned Output Value of 16
  • Calculating Expression 
    • 2 ** 4
    • 16
Analysis, Main Findings and Conclusions
Analysis
  • In above Expression 
    • Operator is 
      • **
    • Operand 01 is
      • A Constant (i.e., 2)
    • Operand 02 is
      • A Constant (i.e., 4)
  • Analysis 
    • In this Expression, we performed a Simple Arithmetic Operation i.e., Calculated the Exponent of Two Integer Constants
Main Findings
  • Finding 01
    • When we use Constants in an Expression 
      • Constants (Values) are used in performing Arithmetic Operations (Calculations)
  • Finding 02
    • An Expression returns only a Single Output Value 
  • Finding 03
    • We can use Expressions to perform various useful Real-world Tasks
Conclusions
  • Expressions help us to perform Arithmetic Operations (Calculations) to accomplish various Real-world Tasks  

 

  • Example 2 - Exponent Operator
Completely and Correctly Understand the Task
Task Description
  • What Output Value will be returned by the Expression given in the following Python Program?
    • Python Statement
      • number1 = 5
      • number2 = number1 ** 2
    • Expression
      • number1 ** 2
  • In above Expression
    • Operator
      • **
    •  Operand 01
      • number1 (Variable)
    • Operand 02
      • 2 (Constant)
Plan and Design Solution to the Task
Input-Processing-Output
  • Input
    • Data
      • An Expression
    • Instruction(s)
      • Perform Arithmetic Operation(s) by applying Arithmetic Operators on the Operands given in the Expression
  • Output
    • A Single Value (obtained by performing Arithmetic Operation(s)) 
  • Processing
    • Step  1: Perform Arithmetic Operation(s) – Apply Arithmetic Operator (**) on the Operands given in the Expression
    • Step  2: Store Result (Output Value) returned by Expression in Variable (number1)
Output – Returned by Expression
25
Reason – Why Expression Returned Output Value of 25
  • Value of Variable (number1) is 5
  • Calculating Expression 
    • number1 ** 2 
    • 5 ** 2
    • 25
Analysis, Main Findings and Conclusions
Analysis
  • In above Expression 
    • Operator is 
      • **
    • Operand 01 is
      • A Variable (i.e., number1)
    • Operand 02 is
      • A Constant (i.e., 2)
  • Analysis 
    • In this Expression, we performed a Simple Arithmetic Operation i.e., Calculated the Exponent of Two Integers (One Variable and One Constant)
Main Findings
  • Finding 01
    • When we use Variables in an Expression 
      • Values of Variables are used in performing Arithmetic Operations (Calculations)
  • Finding 02
    • When we use Constants in an Expression 
      • Constants (Values) are used in performing Arithmetic Operations (Calculations)
  • Finding 03
    • An Expression returns only a Single Output Value 
  • Finding 04
    • We can use Expressions to perform various useful Real-world Tasks
Conclusions
  • Expressions help us to perform Arithmetic Operations (Calculations) to accomplish various Real-world Tasks  
  • Example 3 - Exponent Operator
Completely and Correctly Understand the Task
Task Description
  • What Output Value will be returned by the Expression given in the following Python Program?
    • Python Statement
      • number1 = 3.8
      • number2 = 1.4
      • number3 = number1 ** number2
    • Expression
      • number1 ** number2
  • In above Expression
    • Operator
      • **
    • Operand 01
      • number1 (Variable)
    • Operand 02
      • number2 (Variable)
Plan and Design Solution to the Task
Input-Processing-Output
  • Input
    • Data
      • An Expression
    • Instruction(s)
      • Perform Arithmetic Operation(s) by applying Arithmetic Operators on the Operands given in the Expression
  • Output
    • A Single Value (obtained by performing Arithmetic Operation(s)) 
  • Processing
    • Step  1: Perform Arithmetic Operation(s) – Apply Arithmetic Operator (**) on the Operands given in the Expression
    • Step  2: Store Result (Output Value) returned by Expression in Variable (number1)
Output – Returned by Expression
6.48
Reason – Why Expression Returned Output Value of 6.48
  • Value of Variable (number1) is 3.8
  • Value of Variable (number2) is 1.4
  • Calculating Expression 
    • number1 ** number2
    • 3.8 ** 1.4
    • 6.48
Analysis, Main Findings and Conclusions
Analysis
  • In above Expression 
    • Operator is 
      • **
    • Operand 01 is
      • A Variable (i.e., number1)
    • Operand 02 is
      • A Variable (i.e., number2)
  • Analysis 
    • In this Expression, we performed a Simple Arithmetic Operation i.e., Calculated the Exponent of Two Float Variables
Main Findings
  • Finding 01
    • When we use Variables in an Expression 
      • Values of Variables are used in performing Arithmetic Operations (Calculations)
  • Finding 02
    • An Expression returns only a Single Output Value 
  • Finding 03
    • We can use Expressions to perform various useful Real-world Tasks
Conclusions
  • Expressions help us to perform Arithmetic Operations (Calculations) to accomplish various Real-world Tasks  

 

  • Comparing Example 1 vs Example 2 vs Example 3
Example 1 – Expression is 2 ** 4
  • In Example 1 – Expression is 2 ** 4
    • Both Operands are Integer Constants 
      • Operand 01
        • 2
      • Operand 02
        • 4
    • Output Value – Returned by Expression is an Integer Constant
      • 16
Example 2 – Expression is number1 ** 2
  • In Example 2 – Expression is number1 ** 2
    • First Operand is an Integer Variable and Second Operand is an Integer Constant 
      • Operand 01
        • number1
      • Operand 02
        • 2
    • Output Value – Returned by Expression is an Integer Constant
      • 25
Example 3 – Expression is number1 ** number2
  • In Example 3 – Expression is number1 ** number2
    • First Operand is a Float Variable and Second Operand is also a Float Variable 
      • Operand 01
        • number1
      • Operand 02
        • number2
    • Output Value – Returned by Expression is a Float Constant
      • 6.48
Analysis
  • Analysis and Main Finding 
    • Finding 01
      • In all three Examples (Example 1, Example 2 and Example 3), Expression either returned an
        • Integer Value (Constant) or 
        • Float Value (Constant)
Conclusion
  • These Examples indicate that Expression always returns an 
    • Output Value 

Division Operator

  • Division Operator
  • Symbol
    • /
  • Purpose 
    • Divide One Value with another Value 
  • / Operator Usage in an Expression 
    • Operand 01 / Operand 02
  • How / Operator Works 
    • Divide Operand 01 by Operand 02 and 
      • returns a Single Output Value
  • Dividend, Divisor and Quotient
  • In Division, a Value (Number) is divided by any other Value (Number) to get another Value (Number) as Output 
  • Dividend 
    • The Value (Number) which is getting divided is called Dividend
  • Divisor 
    • The Value (Number) which divides a given Value (Number) is called Divisor
  • Quotient 
    • The Output Value (Number) which we get as a result is called Quotient
  • Example 1 - Dividend, Divisor and Quotient
Task Description
  • Identify the Values of Dividend, Divisor and Quotient in the following Expression
Expression, Dividend, Divisor and Quotient
  • Expression
    • 10 / 4 = 2
  • Dividend
    • 10
  • Divisor
    • 4
  • Quotient
    • 2

 

  • Example 2 - Dividend, Divisor and Quotient
Task Description
  • Identify the Values of Dividend, Divisor and Quotient in the following Expression
Expression, Dividend, Divisor and Quotient
  • Expression
    • 10.0 / 4.0 = 2.5
  • Dividend
    • 10.0
  • Divisor
    • 4.0
  • Quotient
    • 2.5
  • Example 3 - Dividend, Divisor and Quotient
Task Description
  • Identify the Values of Dividend, Divisor and Quotient in the following Expression
Expression, Dividend, Divisor and Quotient
  • Expression
    • 10.0 / 4 = 2.5
  • Dividend
    • 10.0
  • Divisor
    • 4
  • Quotient
    • 2.5
  • Example 4- Dividend, Divisor and Quotient
Task Description
  • Identify the Values of Dividend, Divisor and Quotient in the following Expression
Expression, Dividend, Divisor and Quotient
  • Expression
    • 10 / 4.0 = 2.5
  • Dividend
    • 10
  • Divisor
    • 4.0
  • Quotient
    • 2.5
  • Comparing Example 1, Example 2, Example 3 and Example 4

 

Example 1 – Expression is 10 / 4 
  • In Example 1 – Expression is: 10 / 4 = 2
    • Dividend, Divisor and Quotient, all are
      • Integer Values (Constants) 
Example 2 – Expression is 10.0 / 4.0 
  • In Example 2 – Expression is: 10.0 / 4.0 = 2.5
    • Dividend, Divisor and Quotient, all are
      • Float Values (Constants) 
Example 3 – Expression is 10.0 / 4
  • In Example 3 – Expression is: 10.0 / 4 = 2.5
    • Dividend is a
      • Float Value (Constant)
    • Divisor is an 
      • Integer Value (Constant) 
    • Quotient is a 
      • Float Value (Constant)
Example 4 – Expression is 10 / 4.0
  • In Example 4 – Expression is: 10 / 4.0 = 2.5
    • Dividend is a
      • Integer Value (Constant) 
    • Divisor is an 
      • Float Value (Constant)
    • Quotient is a 
      • Float Value (Constant)
Analysis
  • Finding 01
    • When both Dividend (Operand 01) and Divisor (Operand 02) are Integer Values (Constants)
      • Quotient is an Integer Value (Constant)
  • Finding 02
    • When both Dividend (Operand 01) and Divisor (Operand 02) are Float Values (Constants) OR 
      • Either of Dividend (Operand 01) or Divisor (Operand 02) is a Float Value (Constant)
        • Quotient is a Float Value (Constant)
Conclusion
  • To get Quotient as an Integer Value (Constant)
    • Both Dividend (Operand 01) and Divisor (Operand 02) must be Integer Values (Constants)
  • To get Quotient as a Float Value (Constant)
    • Both (Dividend and Divisor) or one of them must be a Float Value (Constant) 

 

  • Types of Division
  • In Python, two main Types of Division are 
    • Integer Division
    • Float Division
  • Integer Division
  • Definition 
    • In Integer Division, both Dividend (Operand 01) and Divisor (Operand 02) must be Integer Values (Constants)
      • Consequently, Quotient (Output Value) will also be an Integer Value (Constant)
  • Integer Division - Dividend, Divisor, Quotient and Remainder
  • In Integer Division, an Integer Value (Number) is divided by any other Integer Value (Number) to get another Integer Value (Number) as Output 
  • Dividend 
    • The Integer Value (Number) which is getting divided is called Dividend
  • Divisor 
    • The Integer Value (Number) which divides a given Value (Number) is called Divisor
  • Quotient 
    • The Output (Integer) Value (Number) which we get as a result is called Quotient
  • Remainder 
    • Remainder is an Integer Value, that is left over after dividing Dividend with Divisor to produce Quotient
  • Example – Integer Division (Dividend, Divisor, Quotient and Remainder)
  • Task Description
    • Identify the Values of Dividend, Divisor Quotient and Remainder in the following Expression
  • Expression, Dividend, Divisor and Quotient
    • Expression
      • int(10 / 4) = 2
    • Dividend
      • 10
    • Divisor
      • 4
    • Quotient
      • 2
    • Remainder 
      • 2
  • Float Division
  • Definition 
    • In Float Division, both (Dividend and Divisor) or one of them must be a Float Value (Constant)
      • Consequently, Quotient (Output Value) will also be a Float Value (Constant)
  • Example – Float Division (Dividend, Divisor, Quotient and Remainder)
  • Task Description
    • Identify the Values of Dividend, Divisor Quotient and Remainder in the following Expression
  • Expression, Dividend, Divisor and Quotient
    • Expression
      • 10.0 / 4.0 = 2.5
    • Dividend
      • 10.0
    • Divisor
      • 4.0
    • Quotient
      • 2.5
    • Remainder
      • 0
  • Important Note
  • By default, Python performs Float Division on all Numbers (either Integer or Float)
  • Example 1 – Division in Python 
    • 10 / 4 = 2.5
  • Example 2 – Division in Python
    • 10.0 / 4.0 = 2.5
  • Note that Quotient of Example 1 and Example 2 are exactly same
    • Although in Example 1, both Numbers are Integer and 
    • In Example 2, both Numbers are Float
  • Performing Integer Division in Python
  • Question
    • How can we perform Integer Division in Python?
  • Answer
    • Use int() Type Casting Function
  • Examples – int() Type Casting Function
  • Example 1
    • int(10 / 4) = 2
  • Example 2
    • int(10.0 / 4) = 2
  • Example 3
    • int(10 / 4.0) = 2
  • Example 4
    • int(10.0 / 4.0) = 2

Integer Division

  • Example 1 – Integer Division using / Operator
Completely and Correctly Understand the Task
Task Description
  • What Output Value will be returned by the Expression given in the following Python Program?
    • Python Statement
      • number1 = int(10 / 5)
    • Expression
      • int(10 / 5)
  • In above Expression
    • Operator
      • /
    • Operand 01
      • 10 (Constant)
    • Operand 02
      • 5 (Constant)
Plan and Design Solution to the Task
Input-Processing-Output
  • Input
    • Data
      • An Expression
    • Instruction(s)
      • Perform Arithmetic Operation(s) by applying Arithmetic Operators on the Operands given in the Expression
  • Output
    • A Single Value (obtained by performing Arithmetic Operation(s)) 
  • Processing
    • Step  1: Perform Arithmetic Operation(s) – Apply Arithmetic Operator (/) on the Operands given in the Expression
    • Step  2: Store Result (Output Value) returned by Expression in Variable (number1)
Output – Returned by Expression
2
Reason – Why Expression Returned Output Value of 2
  • Calculating Expression 
    • int(10 / 5)
    • 2
Analysis, Main Findings and Conclusions
Analysis
  • In above Expression 
    • Operator is 
      • /
    • Operand 01 is
      • A Constant (i.e., 10)
    • Operand 02 is
      • A Constant (i.e., 5)
    • Analysis 
      • In this Expression, we performed a Simple Arithmetic Operation i.e., Calculated the Division of Two Integer Constants
Main Findings
  • Finding 01
    • When we use Constants in an Expression 
      • Constants (Values) are used in performing Arithmetic Operations (Calculations)
  • Finding 02
    • An Expression returns only a Single Output Value 
  • Finding 03
    • We can use Expressions to perform various useful Real-world Tasks
Conclusions
  • Expressions help us to perform Arithmetic Operations (Calculations) to accomplish various Real-world Tasks  
  • Example 2 – Integer Division using / Operator
Completely and Correctly Understand the Task
Task Description
  • What Output Value will be returned by the Expression given in the following Python Program?
    • Python Statement
      • number1 = 5
      • number2 = int(number1 / 10)
    • Expression
      • int(number1 / 10)
  • In above Expression
    • Operator
      • /
    • Operand 01
      • number1 (Variable)
    • Operand 02
      • 10 (Constant)
Plan and Design Solution to the Task
Input-Processing-Output
  • Input
    • Data
      • An Expression
    • Instruction(s)
      • Perform Arithmetic Operation(s) by applying Arithmetic Operators on the Operands given in the Expression
  • Output
    • A Single Value (obtained by performing Arithmetic Operation(s)) 
  • Processing
    • Step  1: Perform Arithmetic Operation(s) – Apply Arithmetic Operator (/) on the Operands given in the Expression
    • Step  2: Store Result (Output Value) returned by Expression in Variable (number1)
Output – Returned by Expression
0
Reason – Why Expression Returned Output Value of 0
  • Value of Variable (number1) is 5
  • Calculating Expression 
    • int(number1 / 10) 
    • int(5 / 10)
    • 0
Analysis, Main Findings and Conclusions
Analysis
  • In above Expression 
    • Operator is 
      • /
    • Operand 01 is
      • A Variable (i.e., number1)
    • Operand 02 is
      • A Constant (i.e., 10)
  • Analysis 
    • In this Expression, we performed a Simple Arithmetic Operation i.e., Calculated the Division of Two Integers (One Variable and One Constants)
Main Findings
  • Finding 01
    • When we use Variables in an Expression 
      • Values of Variables are used in performing Arithmetic Operations (Calculations)
  • Finding 02
    • When we use Constants in an Expression 
      • Constants (Values) are used in performing Arithmetic Operations (Calculations)
  • Finding 03
    • An Expression returns only a Single Output Value 
  • Finding 04
    • We can use Expressions to perform various useful Real-world Tasks
Conclusions
  • Expressions help us to perform Arithmetic Operations (Calculations) to accomplish various Real-world Tasks  
  • Example 3 – Integer Division using / Operator
Completely and Correctly Understand the Task
Task Description
  • What Output Value will be returned by the Expression given in the following Python Program?
    • Python Statement
      • number1 = 3.0
      • number2 = 1.0
      • number3 = int(number1 / number2)
    • Expression
      • int(number1 / number2)
  • In above Expression
    • Operator
      • /
    • Operand 01
      • number1 (Variable)
    • Operand 02
      • number2 (Variable)
Plan and Design Solution to the Task
Input-Processing-Output
  • Input
    • Data
      • An Expression
    • Instruction(s)
      • Perform Arithmetic Operation(s) by applying Arithmetic Operators on the Operands given in the Expression
  • Output
    • A Single Value (obtained by performing Arithmetic Operation(s)) 
  • Processing
    • Step  1: Perform Arithmetic Operation(s) – Apply Arithmetic Operator (/) on the Operands given in the Expression
    • Step  2: Store Result (Output Value) returned by Expression in Variable (number1)
Output – Returned by Expression
3.0
Reason – Why Expression Returned Output Value of 3.0
  • Value of Variable (number1) is 3.0
  • Value of Variable (number2) is 1.0
  • Calculating Expression 
    • int(number1 / number2) 
    • 3.0 / 1.0
    • 3.0
Analysis, Main Findings and Conclusions
Analysis
  • In above Expression 
    • Operator is 
      • /
    • Operand 01 is
      • A Variable (i.e., number1)
    • Operand 02 is
      • A Variable (i.e., number2)
  • Analysis 
    • In this Expression, we performed a Simple Arithmetic Operation i.e., Calculated the Division of Two Integer Variables
Main Findings
  • Finding 01
    • When we use Variables in an Expression 
      • Values of Variables are used in performing Arithmetic Operations (Calculations)
  • Finding 02
    • An Expression returns only a Single Output Value 
  • Finding 03
    • We can use Expressions to perform various useful Real-world Tasks
Conclusions
  • Expressions help us to perform Arithmetic Operations (Calculations) to accomplish various Real-world Tasks  

 

  • Comparing Example 1, Example 2, Example 3 and Example 4
Example 1 – Expression is 10 / 5
  • In Example 1 – Expression is 10 / 5
    • Both Operands are Integer Constants 
      • Operand 01
        • 10
      • Operand 02
        • 5
    • Output Value – Returned by Expression is an Integer Constant
      • 2
Example 2 – Expression is number1 / 10
  • In Example 2 – Expression is number1 / 10
    • First Operand is an Integer Variable and Second Operand is an Integer Constant 
      • Operand 01
        • number1
      • Operand 02
        • 10
    • Output Value – Returned by Expression is an Integer Constant
      • 0.5
Example 3 – Expression is number1 / number2
  • In Example 3 – Expression is number1 / number2
    • First Operand is a Float Variable and Second Operand is also a Float Variable 
      • Operand 01
        • number1
      • Operand 02
        • number2
    • Output Value – Returned by Expression is a Float Constant
      • 3
Analysis
  • Analysis and Main Finding 
    • Finding 01
      • In all three Examples (Example 1, Example 2 and Example 3), Expression either returned an
        • Integer Value (Constant) or 
        • Float Value (Constant)
Conclusion
  • These Examples indicate that Expression always returns an 
    • Output Value 

 

Float Division

  • Example 1 – Float Division using / Operator
Completely and Correctly Understand the Task
Task Description
  • What Output Value will be returned by the Expression given in the following Python Program?
    • Python Statement
      • number1 = 10.0 / 7.0
    • Expression
      • 10.0 / 7.0
  • In above Expression
    • Operator
      • /
    • Operand 01
      • 10.0 (Constant)
    • Operand 02
      • 7.0 (Constant)
Plan and Design Solution to the Task
Input-Processing-Output
  • Input
    • Data
      • An Expression
    • Instruction(s)
      • Perform Arithmetic Operation(s) by applying Arithmetic Operators on the Operands given in the Expression
  • Output
    • A Single Value (obtained by performing Arithmetic Operation(s)) 
  • Processing
    • Step  1: Perform Arithmetic Operation(s) – Apply Arithmetic Operator (/) on the Operands given in the Expression
    • Step  2: Store Result (Output Value) returned by Expression in Variable (number1)
Output – Returned by Expression
1.43
Reason – Why Expression Returned Output Value of 1.43
  • Calculating Expression 
    • 10.0 / 7.0
    • 1.43
Analysis, Main Findings and Conclusions
Analysis
  • In above Expression 
    • Operator is 
      • /
    • Operand 01 is
      • A Constant (i.e., 10.0)
    • Operand 02 is
      • A Constant (i.e., 7.0)
  • Analysis 
    • In this Expression, we performed a Simple Arithmetic Operation i.e., Calculated the Division of Two Float Constants
Main Findings
  • Finding 01
    • When we use Constants in an Expression 
      • Constants (Values) are used in performing Arithmetic Operations (Calculations)
  • Finding 02
    • An Expression returns only a Single Output Value 
  • Finding 03
    • We can use Expressions to perform various useful Real-world Tasks
Conclusions
  • Expressions help us to perform Arithmetic Operations (Calculations) to accomplish various Real-world Tasks  
  • Example 2 - Float Division using / Operator
Completely and Correctly Understand the Task
Task Description
  • What Output Value will be returned by the Expression given in the following Python Program?
    • Python Statement
      • number1 = 5.0
      • number2 = number1 / 10.0
    • Expression
      • number1 / 10
  • In above Expression
    • Operator
      • /
    • Operand 01
      • number1 (Variable)
    • Operand 02
      • 10.0 (Constant)
Plan and Design Solution to the Task
Input-Processing-Output
  • Input
    • Data
      • An Expression
    • Instruction(s)
      • Perform Arithmetic Operation(s) by applying Arithmetic Operators on the Operands given in the Expression
  • Output
    • A Single Value (obtained by performing Arithmetic Operation(s)) 
  • Processing
    • Step  1: Perform Arithmetic Operation(s) – Apply Arithmetic Operator (/) on the Operands given in the Expression
    • Step  2: Store Result (Output Value) returned by Expression in Variable (number1)
Output – Returned by Expression
0.5
Reason – Why Expression Returned Output Value of 0.5
  • Value of Variable (number1) is 5.0
  • Calculating Expression 
    • number1 / 10.0
    • 5.0 / 10.0
    • 0.5
Analysis, Main Findings and Conclusions
Analysis
  • In above Expression
    •  Operator is 
      • /
    • Operand 01 is
      • A Variable (i.e., number1)
    • Operand 02 is
      • A Constant (i.e., 10.0)
  • Analysis 
    • In this Expression, we performed a Simple Arithmetic Operation i.e., Calculated the Division of Two Floats (One Variable and One Constants) 
Main Findings
  • Finding 01
    • When we usve Variables in an Expression 
      • Values of Variables are used in performing Arithmetic Operations (Calculations)
  • Finding 02
    • When we use Constants in an Expression 
      • Constants (Values) are used in performing Arithmetic Operations (Calculations)
  • Finding 03
    • An Expression returns only a Single Output Value 
  • Finding 04
    • We can use Expressions to perform various useful Real-world Tasks
Conclusions
  • Expressions help us to perform Arithmetic Operations (Calculations) to accomplish various Real-world Tasks  

 

  • Example 3 - Float Division using / Operator
Completely and Correctly Understand the Task
Task Description
  • What Output Value will be returned by the Expression given in the following Python Program?
    • Python Statement
      • number1 = 3.8
      • number2 = 1.4
      • number3 = number1 / number2
    • Expression
      • number1 / number2
  • In above Expression
    • Operator
      • /
    • Operand 01
      • number1 (Variable)
    • Operand 02
      • number2 (Variable)
Plan and Design Solution to the Task
Input-Processing-Output
  • Input
    • Data
      • An Expression
    • Instruction(s)
      • Perform Arithmetic Operation(s) by applying Arithmetic Operators on the Operands given in the Expression
  • Output
    • A Single Value (obtained by performing Arithmetic Operation(s)) 
  • Processing
    • Step  1: Perform Arithmetic Operation(s) – Apply Arithmetic Operator (/) on the Operands given in the Expression
    • Step  2: Store Result (Output Value) returned by Expression in Variable (number1)
Output – Returned by Expression
2.71
Reason – Why Expression Returned Output Value of 2.71
  • Value of Variable (number1) is 3.8
  • Value of Variable (number2) is 1.4
  • Calculating Expression 
    • number1 / number2
    • 3.8 / 1.4
    • 2.71
Analysis, Main Findings and Conclusions
Analysis
  • In above Expression
    • Operator is 
      • /
    • Operand 01 is
      • A Variable (i.e., number1)
    • Operand 02 is
      • A Variable (i.e., number2)
  • Analysis 
    • In this Expression, we performed a Simple Arithmetic Operation i.e., Calculated the Division of Two Float Variables
Main Findings
  • Finding 01
    • When we use Variables in an Expression 
      • Values of Variables are used in performing Arithmetic Operations (Calculations)
  • Finding 02
    • An Expression returns only a Single Output Value 
  • Finding 03
    • We can use Expressions to perform various useful Real-world Tasks
Conclusions
  • Expressions help us to perform Arithmetic Operations (Calculations) to accomplish various Real-world Tasks  

 

  • Comparing Example 1, Example 2, Example 3 and Example 4
Example 1 – Expression is 10.0 / 7.0
  • In Example 1 – Expression is 10.0 / 7.0
    • Both Operands are Integer Constants 
      • Operand 01
        • 10.0
      • Operand 02
        • 7.0
    • Output Value – Returned by Expression is an Integer Constant
      • 1.42
Example 2 – Expression is number1 / 10.0
  • In Example 2 – Expression is number1 / 10.0
    • First Operand is an Integer Variable and Second Operand is a Float Constant 
      • Operand 01
        • number1
      • Operand 02
        • 10.0
    • Output Value – Returned by Expression is an Integer Constant
      • 0.5
Example 3 – Expression is number1 / number2
  • In Example 3 – Expression is number1 / number2
    • First Operand is a Float Variable and Second Operand is also a Float Variable 
      • Operand 01
        • number1
      • Operand 02
        • number2
    • Output Value – Returned by Expression is a Float Constant
      • 2.71
Analysis
  • Analysis and Main Finding 
    • Finding 01
      • In all three Examples (Example 1, Example 2 and Example 3), Expression either returned an
        • Integer Value (Constant) or 
        • Float Value (Constant)
Conclusion
  • These Examples indicate that Expression always returns an 
    • Output Value 

Modulus Operator

  • Modulus Operator
  • Symbol
    • %
  • Purpose 
    • Divide One Value (Number) by another Value (Number) and return the Remainder 
  • % Operator Usage in an Expression 
    • Operand 01 % Operand 02
  • How % Operator Works 
    • Divide Operand 01 with Operand 02 and 
      • returns a Single Output Value 
  • Important Note 
    • We can only use Modulus (%) Operator, when
      • Both Operands (Dividend and Divisor) are
        • Integer Values (Constants)
  • Example 1 - Modulus Operator
Completely and Correctly Understand the Task
Task Description
  • What Output Value will be returned by the Expression given in the following Python Program?
    • Python Statement
      • number1 = 10 % 7
    • Expression
      • 10 % 7
  • In above Expression
    • Operator
      • %
    • Operand 01
      • 10 (Constant)
    • Operand 02
      • 7 (Constant)
Plan and Design Solution to the Task
Input-Processing-Output
  • Input
    • Data
      • An Expression
    • Instruction(s)
      • Perform Arithmetic Operation(s) by applying Arithmetic Operators on the Operands given in the Expression
  • Output
    • A Single Value (obtained by performing Arithmetic Operation(s)) 
  • Processing
    • Step  1: Perform Arithmetic Operation(s) – Apply Arithmetic Operator (%) on the Operands given in the Expression
    • Step  2: Store Result (Output Value) returned by Expression in Variable (number1)
Output – Returned by Expression
3
Reason – Why Expression Returned Output Value of 3
  • Calculating Expression 
    • 10 % 7
    • 3
Analysis, Main Findings and Conclusions
Analysis
  • In above Expression
    • Operator is 
      • %
    • Operand 01 is
      • A Constant (i.e., 10)
    • Operand 02 is
      • A Constant (i.e., 7)
  • Analysis 
    • In this Expression, we performed a Simple Arithmetic Operation i.e., Calculated the Modulus of Two Integer Constants
Main Findings
  • Finding 01
    • When we use Constants in an Expression 
      • Constants (Values) are used in performing Arithmetic Operations (Calculations)
  • Finding 02
    • An Expression returns only a Single Output Value 
  • Finding 03
    • We can use Expressions to perform various useful Real-world Tasks
Conclusions
  • Expressions help us to perform Arithmetic Operations (Calculations) to accomplish various Real-world Tasks  

 

  • Example 2 - Modulus Operator
Completely and Correctly Understand the Task
Task Description
  • What Output Value will be returned by the Expression given in the following Python Program?
    • Python Statement
      • number1 = 5
      • number2 = number1 % 10
    • Expression
      • number1 % 10
  • In above Expression
    • Operator
      • %
    • Operand 01
      • number1 (Variable)
    • Operand 02
      • 10 (Constant)
Plan and Design Solution to the Task
Input-Processing-Output
  • Input
    • Data
      • An Expression
    • Instruction(s)
      • Perform Arithmetic Operation(s) by applying Arithmetic Operators on the Operands given in the Expression
  • Output
    • A Single Value (obtained by performing Arithmetic Operation(s)) 
  • Processing
    • Step  1: Perform Arithmetic Operation(s) – Apply Arithmetic Operator (%) on the Operands given in the Expression
    • Step  2: Store Result (Output Value) returned by Expression in Variable (number1)
Output – Returned by Expression
5
Reason – Why Expression Returned Output Value of 5
  • Value of Variable (number1) is 5
  • Calculating Expression 
    • number1 % 10
    • 5 % 10
    • 5
Analysis, Main Findings and Conclusions
Analysis
  • In above Expression 
    • Operator is 
      • %
    • Operand 01 is
      • A Variable (i.e., number1)
    • Operand 02 is
      • A Constant (i.e., 10)
  • Analysis 
    • In this Expression, we performed a Simple Arithmetic Operation i.e., Calculated the Modulus of Two Integers (One Variable and One Constants)
Main Findings
  • Finding 01
    • When we use Variables in an Expression 
      • Values of Variables are used in performing Arithmetic Operations (Calculations)
  • Finding 02
    • When we use Constants in an Expression 
      • Constants (Values) are used in performing Arithmetic Operations (Calculations)
  • Finding 03
    • An Expression returns only a Single Output Value 
  • Finding 04
    • We can use Expressions to perform various useful Real-world Tasks
Conclusions
  • Expressions help us to perform Arithmetic Operations (Calculations) to accomplish various Real-world Tasks  

 

  • Example 3 - Modulus Operator
Completely and Correctly Understand the Task
Task Description
  • What Output Value will be returned by the Expression given in the following Python Program?
    • Python Statement
      • number1 = 3
      • number2 = 1
      • number3 = number1 % number2
    • Expression
      • number1 % number2
  • In above Expression
    • Operator
      • %
    • Operand 01
      • number1 (Variable)
    • Operand 02
      • number2 (Variable)
Plan and Design Solution to the Task
Input-Processing-Output
  • Input
    • Data
      • An Expression
    • Instruction(s)
      • Perform Arithmetic Operation(s) by applying Arithmetic Operators on the Operands given in the Expression
  • Output
    • A Single Value (obtained by performing Arithmetic Operation(s)) 
  • Processing
    • Step  1: Perform Arithmetic Operation(s) – Apply Arithmetic Operator (%) on the Operands given in the Expression
    • Step  2: Store Result (Output Value) returned by Expression in Variable (number1)
Output – Returned by Expression
0
Reason – Why Expression Returned Output Value of 0
  • Value of Variable (number1) is 3
  • Value of Variable (number2) is 1
  • Calculating Expression 
    • number1 % number2
    • 3 % 1
    • 0
Analysis, Main Findings and Conclusions
Analysis
  • In above Expression 
    • Operator is 
      • %
    • Operand 01 is
      • A Variable (i.e., number1)
    • Operand 02 is
      • A Variable (i.e., number2)
  • Analysis 
    • In this Expression, we performed a Simple Arithmetic Operation i.e., Calculated the Modulus of Two Integers Variables
Main Findings
  • Finding 01
    • When we use Variables in an Expression 
      • Values of Variables are used in performing Arithmetic Operations (Calculations)
  • Finding 02
    • An Expression returns only a Single Output Value 
  • Finding 03
    • We can use Expressions to perform various useful Real-world Tasks
Conclusions
  • Expressions help us to perform Arithmetic Operations (Calculations) to accomplish various Real-world Tasks  

 

  • Comparing Example 1, Example 2, Example 3 and Example 4
Example 1 – Expression is 10 % 7
  • In Example 1 – Expression is 10 % 7
    • Both Operands are Integer Constants 
      • Operand 01
        • 10
      • Operand 02
        • 7
    • Output Value – Returned by Expression is an Integer Constant
      • 3
Example 2 – Expression is number1 % 10
  • In Example 2 – Expression is number1 % 10
    • First Operand is an Integer Variable and Second Operand is an Integer Constant 
      • Operand 01
        • number1
      • Operand 02
        • 10
    • Output Value – Returned by Expression is an Integer Constant
      • 5
Example 3 – Expression is number1 % number2
  • In Example 3 – Expression is number1 % number2
    • First Operand is a Float Variable and Second Operand is also a Float Variable 
      • Operand 01
        • number1
      • Operand 02
        • number2
    • Output Value – Returned by Expression is a Float Constant
      • 0
Analysis
  • Analysis and Main Finding 
    • Finding 01
      • In all three Examples (Example 1, Example 2 and Example 3), Expression either returned an
        • Integer Value (Constant) or 
        • Float Value (Constant)
Conclusion
  • These Examples indicate that Expression always returns an 
    • Output Value 
  • Difference between Division Operator and Modulus Operator
  • Division Operator /
    • When we divide an Integer Value (Dividend) by any other Integer Value (Divisor), / Operator returns
      • Quotient
  • Modulus Operator %
    • When we divide an Integer Value (Dividend) by any other Integer Value (Divisor), % Operator returns
      • Remainder 
  • Important Note
  • By default, in Python, for Modulus Operator
    • Integer Numbers are treated as Integers
    • There is no need to use int() Type Casting Function 
  • Example 1
    • 10 % 7 = 3
  • Example 2
    • 7 % 13 = 7
  • Example 1 - Division Operator and Modulus Operator
Completely and Correctly Understand the Task
Task Description
  • Consider the following two Expressions and observe the Output Values returned by Expressions when we use / and % Operators 😊
Plan and Design Solution to the Task
Input-Processing-Output
  • Input
    • Data
      • An Expression
    • Instruction(s)
      • Perform Arithmetic Operation(s) by applying Arithmetic Operators on the Operands given in the Expression
  • Output
    • A Single Value (obtained by performing Arithmetic Operation(s)) 
  • Processing
    • Perform Arithmetic Operation(s) – Apply Arithmetic Operator (% and /) on the Operands given in the Expression
Expression
  • Expression 01
    • int(10 / 7) = 1
  • Expression 02
    • 10 % 7 = 3
Analysis, Main Findings and Conclusions
Analysis
  • In above Expressions 
    • Operators are
      • / and %
    • Operand 01 is
      • A Constant (i.e., 10)
    • Operand 02 is
      • A Constant (i.e., 7)
    • Analysis 
      • In this Expression, we performed a Simple Arithmetic Operation i.e., Calculated the Modulus and Division of Two Integer Constants
Main Findings
  • Finding 01
    • When we use Constants in an Expression 
      • Constants (Values) are used in performing Arithmetic Operations (Calculations)
  • Finding 02
    • An Expression returns only a Single Output Value 
  • Finding 03
    • We can use Expressions to perform various useful Real-world Tasks
Conclusions
  • The action performed by / and % Operators are
    • entirely different 😊

 

  • Example 2 - Division Operator and Modulus Operator
Completely and Correctly Understand the Task
Task Description
  • Consider the following two Expressions and observe the Output Values returned by Expressions when we use / and % Operators 😊
Plan and Design Solution to the Task
Input-Processing-Output
  • Input
    • Data
      • An Expression
    • Instruction(s)
      • Perform Arithmetic Operation(s) by applying Arithmetic Operators on the Operands given in the Expression
  • Output
    • A Single Value (obtained by performing Arithmetic Operation(s)) 
  • Processing
    • Perform Arithmetic Operation(s) – Apply Arithmetic Operator (% and /) on the Operands given in the Expression
Expression
  • Expression 01
    • 13 / 17 = 0.76
  • Expression 02
    • 13 % 17 = 13
Analysis, Main Findings and Conclusions
Analysis
  • In above Expressions 
    • Operators are
      • / and %
    • Operand 01 is
      • A Constant (i.e., 13)
    • Operand 02 is
      • A Constant (i.e., 17)
    • Analysis 
      • In this Expression, we performed a Simple Arithmetic Operation i.e., Calculated the Modulus and Division of Two Integer Constants
Main Findings
  • Finding 01
    • When we use Variables in an Expression 
      • Values of Variables are used in performing Arithmetic Operations (Calculations)
  • Finding 02
    • When we use Constants in an Expression 
      • Constants (Values) are used in performing Arithmetic Operations (Calculations)
  • Finding 03
    • An Expression returns only a Single Output Value 
  • Finding 04
    • We can use Expressions to perform various useful Real-world Tasks
Conclusions
  • The action performed by / and % Operators are
    • entirely different 😊
  • Example 3 - Division Operator and Modulus Operator
Completely and Correctly Understand the Task
Task Description
  • Consider the following two Expressions and observe the Output Values returned by Expressions when we use / and % Operators 😊
Plan and Design Solution to the Task
Input-Processing-Output
  • Input
    • Data
      • An Expression
    • Instruction(s)
      • Perform Arithmetic Operation(s) by applying Arithmetic Operators on the Operands given in the Expression
  • Output
    • A Single Value (obtained by performing Arithmetic Operation(s)) 
  • Processing
    • Perform Arithmetic Operation(s) – Apply Arithmetic Operator (% and /) on the Operands given in the Expression
Expression
  • Expression 01
    • 10 / 5 = 2
  • Expression 02
    • 10 % 5 = 0
Analysis, Main Findings and Conclusions
Analysis
  • In above Expressions 
    • Operator is 
      • /, %
    • Operand 01 is
      • A Constant (i.e., 10)
    • Operand 02 is
      • A Constant (i.e., 5)
    • Analysis 
      • In this Expression, we performed a Simple Arithmetic Operation i.e., Calculated the Modulus and Division of Two Integer Constants
Main Findings
  • Finding 01
    • When we use Variables in an Expression 
      • Values of Variables are used in performing Arithmetic Operations (Calculations)
  • Finding 02
    • An Expression returns only a Single Output Value 
  • Finding 03
    • We can use Expressions to perform various useful Real-world Tasks
Conclusions
  • The action performed by / and % Operators are
    • entirely different 😊
  • Example 4 - Division Operator and Modulus Operator
Completely and Correctly Understand the Task
Task Description
  • Consider the following two Expressions and observe the Output Values returned by Expressions when we use / and % Operators 😊
Plan and Design Solution to the Task
Input-Processing-Output
  • Input
    • Data
      • An Expression
    • Instruction(s)
      • Perform Arithmetic Operation(s) by applying Arithmetic Operators on the Operands given in the Expression
  • Output
    • A Single Value (obtained by performing Arithmetic Operation(s)) 
  • Processing
    • Perform Arithmetic Operation(s) – Apply Arithmetic Operator (% and /) on the Operands given in the Expression
Expression
  • Expression 01
    • int(10 / 4) = 2
  • Expression 02
    • 10 % 4 = 2
Analysis, Main Findings and Conclusions
Analysis
  • In above Expressions  
    • Operator is 
      • /, %
    • Operand 01 is
      • A Constant (i.e., 10)
    • Operand 02 is
      • A Constant (i.e., 4)
    • Analysis 
      • In this Expression, we performed a Simple Arithmetic Operation i.e., Calculated the Modulus and Division of Two Integer Constants
Main Findings
  • Finding 01
    • When we use Variables in an Expression 
      • Values of Variables are used in performing Arithmetic Operations (Calculations)
  • Finding 02
    • An Expression returns only a Single Output Value 
  • Finding 03
    • We can use Expressions to perform various useful Real-world Tasks
Conclusions
  • The action performed by / and % Operators are
    • entirely different 😊

 

TODO and Your Turn​

Todo Tasks
Your Turn Tasks
Todo Tasks

TODO Task 1

  • Task
    • Consider the following Python Programs and answer the questions given below
  • Note 
    • Your answer should be
      • Well Justified
  • Questions
    • Write Python Programs for all the Tasks given above by following the Template given in this Chapter i.e.
      • Identify following
        • Expression
        • Operator
        • Operands
        • Output returned by Expression
        • Reason – Why Expression Returned Output Value
        • Analysis
        • Findings
        • Conclusion

 

Completely and Correctly Understand the Task
Task 01
  • What Output Value will be returned by the Expression given in the following Python Program?
    • Python Program 
      • number1 = 100 + 50

 

Completely and Correctly Understand the Task
Task 02
  • What Output Value will be returned by the Expression given in the following Python Program?
    • Python Program
      • number1 = 50
      • number1 = number1 + 100

 

Completely and Correctly Understand the Task
Task 03
  • What Output Value will be returned by the Expression given in the following Python Program?
    • Python Program
      • number1 = 100.23
      • number2 = 50.32
      • number3 = number1 + number2 

 

Completely and Correctly Understand the Task
Task 04
  • What Output Value will be returned by the Expression given in the following Python Program?
    • Python Program 
      • number1 = 150 – 200

 

Completely and Correctly Understand the Task
Task 05
  • What Output Value will be returned by the Expression given in the following Python Program?
    • Python Program
      • number1 = 200
      • number1 = number1 – 150

 

Completely and Correctly Understand the Task
Task 06
  • What Output Value will be returned by the Expression given in the following Python Program?
    • Python Program
      • number1 = 30.26
      • number2 = 14.15
      • number3 = number1 – number2 

 

Completely and Correctly Understand the Task
Task 07
  • What Output Value will be returned by the Expression given in the following Python Program?
    • Python Program 
      • number1 =  50 * 4

 

Completely and Correctly Understand the Task
Task 08
  • What Output Value will be returned by the Expression given in the following Python Program?
    • Python Program
      • number1 = 100
      • number1 = number1 * 4

 

Completely and Correctly Understand the Task
Task 09
  • What Output Value will be returned by the Expression given in the following Python Program?
    • Python Program
      • number1 = 65.8
      • number2 = 3.0
      • number3 = number1 * number2 

 

Completely and Correctly Understand the Task
Task 10
  • What Output Value will be returned by the Expression given in the following Python Program?
    • Python Program 
      • number1 =  50 / 1

 

Completely and Correctly Understand the Task
Task 11
  • What Output Value will be returned by the Expression given in the following Python Program?
    • Python Program
      • number1 = 100
      • number1 = number1 / 0

 

Completely and Correctly Understand the Task
Task 12
  • What Output Value will be returned by the Expression given in the following Python Program?
    • Python Program
      • number1 = 0
      • number2 = 3.0
      • number3 = number1 / number2 
Completely and Correctly Understand the Task
Task 13
  • What Output Value will be returned by the Expression given in the following Python Program?
    • Python Program 
      • number1 =  25 ** 2

 

Completely and Correctly Understand the Task
Task 14
  • What Output Value will be returned by the Expression given in the following Python Program?
    • Python Program
      • number1 = 10
      • number1 = number1 ** 0

 

Completely and Correctly Understand the Task
Task 15
  • What Output Value will be returned by the Expression given in the following Python Program?
    • Python Program
      • number1 = 2.50
      • number2 = 1.0
      • number3 = number1 ** number2 

 

Completely and Correctly Understand the Task
Task 16
  • What Output Value will be returned by the Expression given in the following Python Program?
    • Python Program 
      • number1 =  35 % 2

 

Completely and Correctly Understand the Task
Task 17
  • What Output Value will be returned by the Expression given in the following Python Program?
    • Python Program
      • number1 = 105
      • number1 = number1 % 11

 

Completely and Correctly Understand the Task
Task 18
  • What Output Value will be returned by the Expression given in the following Python Program?
    • Python Program
      • number1 = 12.5
      • number2 = 6.0
      • number3 = number1 % number2 

 

Your Turn Tasks

Your Turn Task 1

  • Task
    • Write at least 10 different Python Programs which contain Expressions (very similar to the ones given in the TODO Tasks)
    • For each Python Program, perform Calculations on Expression using the following Template (given in this Chapter) i.e. 
    • Identify following 
      • Expression
      • Operator
      • Operands
      • Output returned by Expression 
      • Reason – Why Expression Returned Output Value
      • Analysis
      • Findings
      • Conclusion

Precedence of Operators

  • Recap
  • In previous Sections, we discussed very basic Expression with only
    • One Operator and 
    • Two Operands
  • However, there can be complex Expressions with 
    • Multiple Operators and 
    • More than Two Operands
  • Calculations in Complex Expressions
  • Question
    • In what Order Operators will operate on Operands in a complex Expression?
  • Answer
    • Follow the Precedence of Operators
  • Precedence of Operators
  • Definition
    • The Order in which Operators are applied on Operands in an Expression is called Precedence of Operators 
  • Purpose 
    • The main purpose of Precedence of Operators is to 
      • completely and correctly understand the process of Calculations i.e., how Calculations are made in Expressions
  • Table - Precedence of Operators
  • The Table below shows the Precedence of Operators
    • Note that Level of Precedence is from Top to Bottom i.e. 
      • () has highest Precedence
      • After (), ** Operator has Precedence
      • After ** Operator, *, / and % Operators have Precedence
      • After *, / and % Operators, + and – Operators have Precedence
 
Precedence of Operators

()

Parentheses

**

Exponent

*, /, %

Multiplication, Division, Modulus

+, –

Addition, Subtraction

=

Assignment Operator

Operators with Same Precedence

  • Operators with Same Precedence
  • In Table 1, the following Operators have Same Precedence
    • *, /, %
    • +, –
  • Performing Calculations on Operators with Same Precedence
  • Question
    • How to Perform Calculations when we have Operators with Same Precedence?
  • Answer
    • Perform Calculations from 
      • Left to Right
  • Example 1 – Operators with Same Precedence

 

Completely and Correctly Understand the Task
Task Description
  • Consider the following Expression and perform Arithmetic Operations (Calculations) considering the Precedence of Operators (see Table given above)
Expressions
  • Expression 
    • 10 + 4 * 2 – 5 / 2
Plan and Design Solution to the Task
Input-Processing-Output
  • Input
    • Data
      • An Expression 
    • Instruction(s)
      • Perform Arithmetic Operation(s) by applying Arithmetic Operators on the Operands given in the Expression
  • Output
    • A Single Value (obtained by performing Arithmetic Operation(s)) 
  • Processing
    • Perform Arithmetic Operations (Considering the Precedence of Operators) – Apply Arithmetic Operators on the Operands given in the Expression
    •  
    •  
Calculation, Findings and Conclusion
Calculations
  • Calculating the Expression 
    • 10 + 4 * 2 – 5 / 2
    • Note that Precedence of * and / Operators is same
      • Make Calculations from Left to Right
    • Step  1: Solve *
      • 10 + 4 * 2 – 5 / 2
      • 10 + 8 – 5 / 2
    • Step  2 Solve /
      • 10 + 8 – 5 / 2
      • 10 + 8 – 2.5
    • Note that Precedence of + and – Operators is same
      • Make Calculations from Left to Right
    • Step  3: Solve +
      • 10 + 8 – 2.5
      • 18 – 2.5
    • Step  4: Solve –
      • 18 – 2.5
      • 15.5
Findings
  • Finding 01
    • Precedence of Operators has a significant impact on the result (Output Value) produced by an Expression
  • Finding 02
    • We can easily and quickly write very complex Expressions (to accomplish various Real-world Tasks) if we correctly follow the Precedence of Operators
Conclusion
  • Precedence of Operators help us to understand the process of performing Arithmetic Operations (Calculations) completely and correctly in Expressions i.e., how Calculations are carried out in Expressions

 

  • Example 2 – Operators with Same Precedence
Completely and Correctly Understand the Task
Task Description
  • Consider the following Expression and perform Arithmetic Operations (Calculations) considering the Precedence of Operators (see Table given above)
Expressions
  • Expression 
    • 10.5 + 4.2 * (2 – 5) / 2.0 – 7
Plan and Design Solution to the Task
Input-Processing-Output
  • Input
    • Data
      • An Expression 
    • Instruction(s)
      • Perform Arithmetic Operation(s) by applying Arithmetic Operators on the Operands given in the Expression
  • Output
    • A Single Value (obtained by performing Arithmetic Operation(s)) 
  • Processing
    • Perform Arithmetic Operations (Considering the Precedence of Operators) – Apply Arithmetic Operators on the Operands given in the Expression
    •  
    •  
Calculation, Findings and Conclusion
Calculations
  • Calculating the Expression 
    • 10.5 + 4.2 * (2 – 5) / 2.0 – 7
    • Step  1: Solve ()
      • 10.5 + 4.2 * (2 – 5) / 2.0 – 7
      • 10.5 + 4.2 * – 3 / 2.0 – 7
    • Note that Precedence of * and / Operators is same
      • Make Calculations from Left to Right
    • Step  2: Solve *
      • 10.5 + 4.2 * – 3 / 2.0 – 7
      • 10.5 + -12.6 / 2.0 – 7
    • Step  3 Solve /
      • 10.5 + -12.6 / 2.0 – 7
      • 10.5 + -6.3 – 7
    • Note that Precedence of + and – Operators is same
      • Make Calculations from Left to Right
    • Step  4: Solve +
      • 10.5 + -6.3 – 7
      • 4.2 -7
    • Step  5: Solve –
      • 4.2 – 7
      • – 2.8
Findings
  • Finding 01
    • Precedence of Operators has a significant impact on the result (Output Value) produced by an Expression
  • Finding 02
    • We can easily and quickly write very complex Expressions (to accomplish various Real-world Tasks) if we correctly follow the Precedence of Operators
Conclusion
  • Precedence of Operators help us to understand the process of performing Arithmetic Operations (Calculations) completely and correctly in Expressions i.e., how Calculations are carried out in Expressions

 

  • Example 3 – Operators with Same Precedence
Completely and Correctly Understand the Task
Task Description
  • Consider the following Expression and perform Arithmetic Operations (Calculations) considering the Precedence of Operators (see Table given above)
    • Python Program
      • number1 = 6
      • number2 = 4
      • number3 = 4 ** 3 + (number1 * 3) – number2 /  10 
Expressions
  • Expression 
    • 10.5 + 4.2 * (2 – 5) / 2.0 – 7
Plan and Design Solution to the Task
Input-Processing-Output
  • Input
    • Data
      • An Expression 
    • Instruction(s)
      • Perform Arithmetic Operation(s) by applying Arithmetic Operators on the Operands given in the Expression
  • Output
    • A Single Value (obtained by performing Arithmetic Operation(s)) 
  • Processing
    • Perform Arithmetic Operations (Considering the Precedence of Operators) – Apply Arithmetic Operators on the Operands given in the Expression
  •  
  •  
Calculation, Findings and Conclusion
Calculations
  • Calculating the Expression 
    • 10.5 + 4.2 * (2 – 5) / 2.0 – 7
    • Step  1: Solve ()
      • 10.5 + 4.2 * (2 – 5) / 2.0 – 7
      • 10.5 + 4.2 * – 3 / 2.0 – 7
    • Note that Precedence of * and / Operators is same
      • Make Calculations from Left to Right
    • Step  2: Solve *
      • 10.5 + 4.2 * – 3 / 2.0 – 7
      • 10.5 + -12.6 / 2.0 – 7
    • Step  3 Solve /
      • 10.5 + -12.6 / 2.0 – 7
      • 10.5 + -6.3 – 7
    • Note that Precedence of + and – Operators is same
      • Make Calculations from Left to Right
    • Step  4: Solve +
      • 10.5 + -6.3 – 7
      • 4.2 -7
    • Step  5: Solve –
      • 4.2 – 7
      • – 2.8
Findings
  • Finding 01
    • Precedence of Operators has a significant impact on the result (Output Value) produced by an Expression
  • Finding 02
    • We can easily and quickly write very complex Expressions (to accomplish various Real-world Tasks) if we correctly follow the Precedence of Operators
Conclusion
  • Precedence of Operators help us to understand the process of performing Arithmetic Operations (Calculations) completely and correctly in Expressions i.e., how Calculations are carried out in Expressions

 

  • Example 4 – Operators with Same Precedence
Completely and Correctly Understand the Task
Task Description
  • Consider the following Expression and perform Arithmetic Operations (Calculations) considering the Precedence of Operators (see Table given above)
    • Python Program
      • num1 = 5
      • num2 = 10
      • num3 = 15
      • num4 = 20
      • num5 = (num1 % num2) + (num4 / num1) – (num3 ** 2) * 10
Expressions
  • Expression 
    • (num1 % num2) + (num4 / num1) – (num3 ** 2) * 10
Plan and Design Solution to the Task
Input-Processing-Output
  • Input
    • Data
      • An Expression 
    • Instruction(s)
      • Perform Arithmetic Operation(s) by applying Arithmetic Operators on the Operands given in the Expression
  • Output
    • A Single Value (obtained by performing Arithmetic Operation(s)) 
  • Processing
    • Perform Arithmetic Operations (Considering the Precedence of Operators) – Apply Arithmetic Operators on the Operands given in the Expression
Calculation, Findings and Conclusion
Calculations
  • Value of Variable (num1) = 5
  • Value of Variable (num2) = 10
  • Value of Variable (num3) = 15
  • Value of Variable (num4) = 20
  • Calculating the Expression 
    • (num1 % num2) + (num4 / num1) – (num3 ** 2) * 10
      • (5 % 10) + (20 / 5) – (15 ** 2) * 10
  • Note that Precedence of () Operators is same
    • Make Calculations from Left to Right
  • Step  1: Solve ()
    • (5 % 10) + (20 / 5) – (15 ** 2) * 10
    • 5 + (20 / 5) – (15 ** 2) * 10
  • Step  2 Solve ()
    • 5 + (20 / 5) – (15 ** 2) * 10
    • 5 + 4 – (15 ** 2) * 10
  • Step  3: Solve ()
    • 5 + 4 – (15 ** 2) * 10
    • 5+ 4 – 225 * 10
  • Note that Precedence of + and – Operators is same
    • Make Calculations from Left to Right
  • Step  4: Solve *
    • 5+ 4 – 225 * 10
    • 5 + 4 – 2250
  • Step  5: Solve +
    • 5 + 4 – 2250
    • 20 -2250
  • Step  6: Solve –
    • 20 -2250
    • -2241
Findings
  • Finding 01
    • Precedence of Operators has a significant impact on the result (Output Value) produced by an Expression
  • Finding 02
    • We can easily and quickly write very complex Expressions (to accomplish various Real-world Tasks) if we correctly follow the Precedence of Operators
Conclusion
  • Precedence of Operators help us to understand the process of performing Arithmetic Operations (Calculations) completely and correctly in Expressions i.e., how Calculations are carried out in Expressions

 

  • Example 5 – Operators with Same Precedence
Completely and Correctly Understand the Task
Task Description
  • Consider the following Expression and perform Arithmetic Operations (Calculations) considering the Precedence of Operators (see Table given above)
Expressions
  • Expression 
    • 10.0 + 4.9 * 2.2 – 5.3 / 2.1
Plan and Design Solution to the Task
Input-Processing-Output
  • Input
    • Data
      • An Expression 
    • Instruction(s)
      • Perform Arithmetic Operation(s) by applying Arithmetic Operators on the Operands given in the Expression
  • Output
    • A Single Value (obtained by performing Arithmetic Operation(s)) 
  • Processing
    • Perform Arithmetic Operations (Considering the Precedence of Operators) – Apply Arithmetic Operators on the Operands given in the Expression
Calculation, Findings and Conclusion
Calculations
  • Calculating the Expression 
    • 10.0 + 4.9 * 2.2 – 5.3 / 2.1
  • Note that Precedence of * and / Operators is same
    • Make Calculations from Left to Right
    • Step  1: Solve *
      • 10.0 + 4.9 * 2.2 – 5.3 / 2.1
      • 10.0 + 10.7 – 5.3 / 2.1
    • Step  2 Solve /
      • 10.0 + 10.7 – 5.3 / 2.1
      • 10.0 + 10.7 – 2.5
    • Note that Precedence of + and – Operators is same
      • Make Calculations from Left to Right
    • Step  3: Solve +
      • 10.0 + 10.7 – 2.5
      • 20.7 – 2.5 
    • Step  4: Solve –
      • 20.7 – 2.5
      • 18.2
Findings
  • Finding 01
    • Precedence of Operators has a significant impact on the result (Output Value) produced by an Expression
  • Finding 02
    • We can easily and quickly write very complex Expressions (to accomplish various Real-world Tasks) if we correctly follow the Precedence of Operators
Conclusion
  • Precedence of Operators help us to understand the process of performing Arithmetic Operations (Calculations) completely and correctly in Expressions i.e., how Calculations are carried out in Expressions

 

TODO and Your Turn​

Todo Tasks
Your Turn Tasks
Todo Tasks

TODO Task 1

  • Task
    • Consider the following Python Programs and answer the questions given below 
  • Note
    • Your answers should be
      • Well Justified
  • Question
    • For each Python Program, perform Calculations on Expression using the following Template (given in this Chapter) i.e. 
    • Identify Expression
    • Calculations, Findings and Conclusion
      • Calculations
      • Analysis
      • Findings
      • Conclusion

 

Completely and Correctly Understand a Task

Task 01

  • Consider the following Expression and perform Arithmetic Operations (Calculations) considering the Precedence of Operators (see Table given above)
    • Python Program 01
      • number = 20 + 30 * 60 – 40 / 6 ** 3
    • Python Program 02
      • number = (25 + 35) * (65 – 45) / (5 ** 2)
    • Python Program 03
      • number = 100 + (13 * (35 – 45) / 2) % 3 ** 2
    • Python Program 04
      • number1 = 5
      • number2 = 10
      • number3 = 10 * number2 – (15 + number1) / 5
    • Python Program 05
      • number = 10.7 + (13.2 * (35.0 – 45.0) / 2.75) % 3 ** 2
    • Python Program 06
      • number1 = 5.25
      • number2 = 10.9
      • number3 = 10.25 * number2 – (15.0 + number1) / 5.5
Your Turn Tasks

Your Turn Task 1

  • Task
    • Write at least 10 different Python Programs which contain Expressions (very similar to the ones given in the TODO Tasks)
    • For each Python Program, perform Calculations on Expression using the following Template (given in this Chapter) i.e. 
      • Identify Expression
      • Calculations, Findings and Conclusion
      • Calculations
      • Analysis
      • Findings
      • Conclusion

 

Chapter Summary

  • Chapter Summary

In this Chapter, I presented the following main concepts:

  • Operation 
    • In Computer Programming, an Operation is defined as an action that is carried out to accomplish a given Task
  • Five Basic Computer Operations
    • The five basic Computer Operations are
      • Input
      • Processing
      • Output
      • Store
      • Control
  • Operator
    • In Computer Programming, an Operator is defined as a special Symbol, which is used to carry out Arithmetic / Logical Operations
  • Operand 
    • In Computer Programming, an Operand is defined as the Object (or Value) on which an Operator operates 
  • Expression
    • In Programming Language, an Expression is a combination of Operands (Variables / Constants) and Operator(s) to produce an Output Value 
  • Main Components of an Expression
    • An Expression comprises of Two Main Components
      • Operator
      • Operands
  • Types of Operators
    • The main Types of Operators (in Python) are 
      • Assignment Operator
      • Arithmetic Operators
      • Logical Operators
      • Comparison Operators
      • Membership Operators
      • Identity Operators
  • Assignment Operator
    • Assignment Operator is represented with = Symbol 
  • Arithmetic Operator
    • An Arithmetic Operator is an Operator that takes two Operands and performs Calculation on them
  • Types of Arithmetic Operators in Python
    • In Python, we have following six Arithmetic Operators 
      • Addition 
        • +
      • Subtraction 
        • –
      • Multiplication 
        • *
      • Division 
        • /
      • Exponent 
        • **
      • Modulus  
        • %
  • Exponent 
    • Exponent (or Power) of a Number tells us how many times a Number will be multiplied by itself
  • Dividend, Divisor and Quotient
    • In Division, a Value (Number) is divided by any other Value (Number) to get another Value (Number) as Output 
  • Dividend 
    • The Value (Number) which is getting divided is called Dividend
  • Divisor 
    • The Value (Number) which divides a given Value (Number) is called Divisor
  • Quotient 
    • The Output Value (Number) which we get as a result is called Quotient
  • Types of Division
    • In Python, two main Types of Division are 
      • Integer Division
      • Float Division
  • Integer Division
    • In Integer Division, both Dividend (Operand 01) and Divisor (Operand 02) must be Integer Values (Constants)
    • Consequently, Quotient (Output Value) will also be an Integer Value (Constant)
    • Integer Division – Dividend, Divisor, Quotient and Remainder
    • In Integer Division, an Integer Value (Number) is divided by any other Integer Value (Number) to get another Integer Value (Number) as Output 
  • Dividend 
    • The Integer Value (Number) which is getting divided is called Dividend
  • Divisor 
    • The Integer Value (Number) which divides a given Value (Number) is called Divisor
  • Quotient 
    • The Output (Integer) Value (Number) which we get as a result is called Quotient
  • Remainder 
    • Remainder is an Integer Value, that is left over after dividing Dividend with Divisor to produce Quotient
  • Float Division
    • In Float Division, both (Dividend and Divisor) or one of them must be a Float Value (Constant)
    • Consequently, Quotient (Output Value) will also be a Float Value (Constant)
  • Precedence of Operators
    • The Order in which Operators are applied on Operands in an Expression is called Precedence of Operators

In Next Chapter

  • In Next Chapter
  • In Sha Allah, in the next Chapter, I will present a detailed discussion on
  • Algorithm, Pseudo Code and Flow Charts
Chapter 6 - Variables in Python
  • Previous
Chapter 8 - Algorithm, Pseudocode and Flowcharts
  • Next
Share this article!
Facebook
Twitter
LinkedIn

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

About Us

Ilm O Irfan Technologies believes that honest dedicated hard work with the ethical approach of commitment true to every word, and trust-building is the road to success in any field of business or life.

Quick Links
  • About Us
  • Contact
Useful Links
  • Privacy Policy
  • Terms and Conditions
  • Disclaimer
  • Support
  • FAQ
Subscribe Our Newsletter
Facebook Twitter Linkedin Instagram Youtube

© 2022 Ilmo Irfan. All Rights Reserved.