Need Assistance?

support@tutorialshub.in

Python Fundamentals

Input and output

ADVERTISEMENT
Python Free Lesson
5 min read
ADVERTISEMENT

Arithmetic and comparison

Python provides arithmetic operators such as +, -, *, /, //, % and **. Comparison operators such as ==, !=, < and >= produce boolean results.

Logical expressions

and, or and not combine conditions and use short-circuit evaluation. Membership operators such as in are useful when checking collections. Use is primarily for identity checks such as value is None.

Make business rules readable

Parentheses are useful when an expression represents a business rule. Do not rely on remembering complicated precedence rules when adding parentheses makes the intended calculation obvious.

Practice: calculate an order subtotal, discount, tax and final total, then create a boolean condition that determines whether the customer receives free delivery.

ADVERTISEMENT