Continuing Python!

After so many days I am continuing with Python again. Yes, I was not able to maintain the series properly, but let's get back to work and know what I read next in Python from the book of PYM. In Python most of the lines will have expressions and these expressions are made of operators and operands.

Operators

These are the symbols which tells the python interpretor to do the mathematical operation.

2+3
5
22.0/12
1.83333

To get floating results we need to use the division using any of operand as the floating number. To do modular operation use % operator.


#!/usr/bin/envv python3
days= int(input("Enter days:"))

month= days/30
days= days%30
print("Months= %d days= %d %(month, days))

Relational operators

operator ## meaning

< is less than > is greater than <= is less than or equal to >= is greater than or equal == is equal to != is not equal to

Note: // operator gives floor division result.

4.0//3
1.0

4.0/3
1.33333

Logical operator

To do a logical AND, OR we use these keywords.