0% found this document useful (0 votes)
3 views1 page

Python Programming Notes-22

The document provides an introduction to Python programming, specifically focusing on print statements and operator precedence. It explains how expressions are evaluated based on operator precedence, using examples to illustrate the concepts. Additionally, it demonstrates the use of parentheses to override default precedence in arithmetic operations.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views1 page

Python Programming Notes-22

The document provides an introduction to Python programming, specifically focusing on print statements and operator precedence. It explains how expressions are evaluated based on operator precedence, using examples to illustrate the concepts. Additionally, it demonstrates the use of parentheses to override default precedence in arithmetic operations.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

PYTHON PROGRAMMING III YEAR/II SEM MRCET

>>> college="mrcet"

An print statement is something which is an input from the user, to be printed / displayed on
to the screen (or ) monitor.

>>> print("mrcet colege")

mrcet college

Precedence of Operators:

Operator precedence affects how an expression is evaluated.

For example, x = 7 + 3 * 2; here, x is assigned 13, not 20 because operator * has higher
precedence than +, so it first multiplies 3*2 and then adds into 7.

Example 1:

>>> 3+4*2

11

Multiplication gets evaluated before the addition operation

>>> (10+10)*2

40

Parentheses () overriding the precedence of the arithmetic operators

Example 2:

a = 20
b = 10
c = 15
d=5
e=0

e = (a + b) * c / d #( 30 * 15 ) / 5
print("Value of (a + b) * c / d is ", e)

e = ((a + b) * c) / d # (30 * 15 ) / 5
print("Value of ((a + b) * c) / d is ", e)

e = (a + b) * (c / d); # (30) * (15/5)


17

You might also like