Page 480 - ComputerScience_Class_11
P. 480
12.4.3 Multiple Statement
A multiple statement in Python refers to writing two or more statements on the same line. This is done by separating
each statement with a semicolon (;). Normally, Python executes one statement per line. However, when we want to
write short statements together on a single line, we can use semicolons to separate them.
Program 14: To demonstrate multiple statements in Python.
Program 14.py
File Edit Format Run Options Window Help
# Assigning values to variables and printing the result in a single line
a = 10; b = 20; c = a + b; print("Sum:", c)
# Printing multiple messages in one line using semicolon
print("Hello"); print("Welcome to Python"); print("Learning Multiple Statements")
Output
Sum: 30
Hello
Welcome to Python
Learning Multiple Statements
12.5 OPERATOR PRECEDENCE
Operator precedence refers to the order in which Python evaluates different operators in an expression. When an
expression contains more than one operator, Python follows a predefined priority rule to decide which operation
should be performed first.
• Operators with higher precedence are solved first and operators with lower precedence are solved later.
• If two operators have the same precedence, the expression is evaluated according to associativity (usually left
to right).
The following table shows the Operator precedence in Python along with their description:
Operator Name
() Parentheses
** Exponent
*, /, %, // Multiplication, Division, Modulus, Floor Division
+, – Addition, Subtraction
==, !=, >, <, >=, <= Comparison
=, +=, -=, *=, /=, %=, **=, //= Assignment
not
and Logical
or
478 Touchpad Computer Science (Ver. 3.0)-XI

