Zed-King Institute
    All Notes

    O Level · Chapterwise Notes

    Chapter 4: Operators, Expressions and Python Statements

    Zed-King Study app · Free

    O Level students across India practise here, free

    Daily M1–M4 quizFull 100-question mocksAll-India rank
    Open the free app

    Google login · no Play Store needed

    🏆 Free All-India Sunday Mock · Sun, 29 Nov, 11 AM · CCC + O LevelRegister

    About this PDF

    Operators, expressions, input/output and control statements.

    This is part of the free O Level M3-R5.1 study material in the Zed-King Study Zone. You can read every page above in your browser, or download the file and study offline. Zed-King Group of Institute is a NIELIT Study Centre in Kaithal, Haryana, and all of this material follows the current NIELIT syllabus.

    Course
    O Level — NIELIT Foundation Diploma
    Module
    M3 — M3-R5.1: Programming and Problem Solving through Python
    Section
    Chapterwise Notes
    Format
    PDF — read online or download
    Price
    Free, no sign-up required

    Text from this PDF

    The opening pages as plain text — open the reader above for tables, diagrams and the full file.

    CHAPTER-4 Operators,Expressions and Python Statement Definition Of Operators Operators are used to perform operations on variables and values.

    Expression is the combination of operator and operand.

    c=a+b Types of operator

    1. Arithmetic operators

    2. Assignment operators

    3. Comparison operators Logical operators Identity operators Membership operators Bitwise operator Arithmetic operator Operator Name Addition Subtraction Multiplication Exponential Division Floor Division Modulus (Mod)

    Add value of its operands Subtract the value of right operand from left operand Multiplies value of its operands Return base (left operand) raised to power (right operand)

    exponent.

    Divide the value of left operand with right operand and store quotient in float.

    Same as division, but store quotient after removing the fractional part.

    Same as division, but store remainder.

    (it behave like 53)

    Result Relational /comparison Operators Operator Name Equal to Not equal to Greater than Less than Greater than or equal to Less than or equal to returns True if two operands are equal returns True if two operands are not equal returns True if left operand is greater than right operand returns True if left operand is smaller than right operand returns True if left operand is greater than or equal to right

    operand returns True if left operand is smaller than or equal to right operand Result Logical Operators:

    Operator and not if any of the expression is True then the condition becomes True.

    if both the operands are True, then the condition becomes True.

    reverse the state of expression Expressionl Expression 2 and operator or operator Bitwise Operators:

    Operator Name AND XOR Complement Right Shift Left Shift Compare two bits and generate result 1 if both bits are 1, else return 0.

    Compare two bits and generate result 1 if one of the bit is 1 else return 0.

    Compare two bits and generate result 0 if both the bits are identical (same)

    else return 1, It generate result opposite of the bits i.e. if bit is 0 then it generates 1 and vice versa.

    It shifts the bits of the number to the right and fills 0 on blank left as a result, It gives result very similar as to divide the number with some power of two It shifts the bits of the number to the left and fills 0 on blank left as a result. It gives result very similar as of multiplying the number with some power of two.

    Membership Operators:

    Membership operators are used to check if a value exists in a sequence or not.

    They return the result as True or False.

    There are 2 membership operators in python :

    in : returns True if a values is found in a sequence.

    not in : returns True if a value is not found in a sequence.

    Identity Operators:

    •Identity operators are used to check whether two values are on the same part of the memory or not.

    •They return the result as True or False.

    •There are 2 membership operators in python :

    is : returns True if two operands are identical.

    is not: returns True if two operands are not identical.

    Assignment operators Operator Equals To a = IO a = a-IO a=a/10 a=aff10 a-a IO a=ah10 Operator Precedence Operators ( ) Highest precedence Is, is not, in, not in, Associativity Right - Left Not x And If else Lambda = Lowest Precedence Left Left - Left - Left Left - Right - Left Introduction- Control statements define the direction or flow according to which a program should be executed. In control statements, unless the given

    expression is true, it does not execute its statement.

    There are following 2 types of control statements-

    1. Conditional branching or statement

    2. Looping or iteration Conditional Statements/SeIection Statement:- Control statement means that it does not execute its statement until any condition given in the program is true.

    There are following types of control statements in

    1. if statement

    2. if_else statement

    3. if_elif_else statement

    4. nested if if Staternent:— In an if statement, when the expression is true then the staternent is executed and if the expression is false then it is not executed.

    Syntax if expression .

    if_statement(s)

    if condition:

    statement(s)

    More chapterwise notes for M3-R5.1

    Run these Python programs yourself — free

    Reading code is not the same as writing it. Type any program from these notes into our free online Python compiler (real Python 3 with NumPy, input() works), or study one of the explained programs with its output.

    Prepare for O Level with expert guidance

    Classroom training, practical labs and exam registration at Zed-King Institute, Kaithal.

    Drag me!