PYTHON
INTRODUCTION TO PYTHON
Unit - 1
Unit Outcomes
- Understand Python as a programming language
- Learn applications of Python
- Understand different modes of Python
- Understand basic syntax and keywords
What is Python?
- Python is a high-level, interpreted, interactive and object-oriented scripting
language.
- It is designed to be highly readable.
Features of Python
- Easy to learn
- Expressive language
- Interpreted language
- Cross-platform
- Free and open source
- Object-oriented
Basic Terms
- High-level language
- Interpreted language
- Interactive language
- Scripting language
- Object-oriented language
Python Versions
- Python 1.0
- Python 2.x
- Python 3.x
Modes in Python
- Interactive Mode:
Used for quick testing and debugging.
- Script Mode:
Used to write longer programs and save for later use.
How to Run Python
- Using Python Shell (Interactive mode)
- Using IDEs (PyCharm, VS Code, etc.)
- Using Command Line
Input / Output
- input(): used to get input from user
- print(): used to display output to user
Python Indentation
- Indentation is used to define blocks of code.
- No use of braces {}
- Consistent indentation is crucial.
Variables in Python
- Used to store data
- Dynamically typed
- Example: x = 10
Data Types
- Numeric
- String
- List
- Tuple
- Dictionary
- Boolean
Operators in Python
- Arithmetic
- Relational
- Assignment
- Logical
- Bitwise
- Membership
- Identity
Conditional Statements
- if
- if-else
- if-elif-else
Looping Statements
- while loop
- for loop
- Nested loops
- Loop control statements: break, continue, pass
Control Flow
- Sequence
- Selection
- Iteration
Examples
- Example 1: Basic Calculator
- Example 2: Check Even or Odd
- Example 3: Print Prime Numbers
Thank You
Thank you :)
?