TN Online TestSamacheer Kalvi practice

Python -Variables and Operators - Formula Sheet

Share this chapter: Telegram

Arithmetic Operators and Formulas

Arithmetic operators are used to perform mathematical calculations on numeric operands. The table below outlines each operator's formula, action, and returns:

Operation Python Formula Result Description
Addition a + b Calculates the sum of operands a and b.
Subtraction a - b Calculates the difference when b is subtracted from a.
Multiplication a * b Calculates the product of multiplying a and b.
Standard Division a / b Calculates the floating-point quotient of dividing a by b.
Modulo (Remainder) a % b Yields the mathematical remainder of a divided by b.
Exponentiation a ** b Calculates the value of base a raised to the power of exponent b.
Floor Division a // b Calculates the integer quotient of dividing a by b, discarding the fractional part.

Comparative and Relational Operations

Relational operators determine the comparative relationship between two operands, returning Boolean outcomes (True or False):

Logical Expressions

Logical operators perform Boolean algebra calculations on relational conditions:

Ternary Conditional Expression Formula

The ternary conditional expression calculates and assigns values based on a evaluated predicate statement:

V = T if C else F

Where:

Solved MCQs → Practice test →

More for this chapter

Book Back Questions10 textbook MCQs · solved Additional MCQs15 extra MCQs · solved Practice TestInteractive · instant score Book Back TestTest yourself on the textbook set Additional MCQ TestTest yourself on the extra set Study NotesConcepts & methods

More chapters in Computer Science

View all
1 Function 2 Data Abstraction 3 Scoping 4 Algorithmic Strategies 6 Control Structures 7 Python functions 8 Strings and String manipulation 9 Lists, Tuples, Sets and Dictionary 10 Python Classes and objects 11 Database Concepts 12 Structured Query Language (SQL) 13 Python and CSV files 14 Importing C++ programs in Python. 15 Data manipulation through SQL 16 Data visualization using pyplot: line chart, pie chart and bar chart