Python
Programming
Fundamentals
What is Python?
✓ Python is a high -level, interpreted, and general -purpose programming
language.
✓ Created by Guido van Rossum in 1991.
✓ I t ’s e a s y t o l e a r n b e c a u s e o f i t s s i m p l e s y n t a x a n d r e a d a b l e c o d e .
Used in:
➢ Web development
➢ Data analysis
➢ Machine learning
➢ Automation
➢ Games and apps
Python Features
EASY TO LEARN AND USE
OPEN-SOURCE AND FREE
C R O S S - P L AT F O R M
HUGE COMMUNITY SUPPORT
EXTENSIVE LIBRARIES AND FRAMEWORKS
IDEAL FOR BOTH BEGINNERS AND PROFESSIONALS
Python Syntax Basics
➢ PYTHON CODE IS WRITTEN IN PLAIN ENGLISH WORDS .
➢ NO NEED TO WRITE {} OR ; LIKE IN OTHER LANGUAGES.
➢ U S E S I N D E N TAT I O N ( S PA C E S ) T O D E F I N E B L O C K S .
Variables and Data Types
➢ VA R I A B L E S S T O R E D ATA O R I N F O R M AT I O N
Data Types:
int → whole numbers (10)
float → decimal numbers (3.14)
str → text ("Hello")
bool → True or False
Variables and Data Types
Python has a set of keywords that are reserved words that cannot be used as variable names,
function names, or any other identifiers
Getting User Input and Output
Use print() to show messages
Use input() to get data from users
Operators
Arithmetic: +, -, *, /, %
Comparison: ==, !=, <, >
Logical: and, or, not
Comparison Operators
Logical Operators
Operator Precedence in Python
Python Quiz
What is the result of this expression?
Qn 1. 5 + 3 * 2
Qn 2. (5 + 3) * 2
Qn 3. 10 - 4 / 2
Qn.4. 4 + 6 / 2 – 3
Qn 5. not 3 > 2
Qn 6. 3 > 2 and 4 < 5
Qn 7. 3 > 2 or 4 > 5
Qn 8. 2 + 3 * 4 ** 2
Qn 9. (2 + 3) * (4 + 1)
Qn 10. print(int((5+3)**(1+2)))
Conditional Statements