Python Introduction
Python Introduction
Name: ___________________
1. Introduction
Python is a high-level, interpreted, and general-purpose programming language created by
Guido van Rossum and first released in 1991. Known for its easy-to-read syntax and wide
applicability, Python supports multiple programming paradigms including procedural,
object-oriented, and functional programming. Its simplicity and powerful libraries make it
one of the most popular programming languages today.
2. Working in Python
Working in Python typically involves writing code in:
- IDLE (Integrated Development and Learning Environment)
- Text editors like VS Code, Sublime Text, or PyCharm
- Jupyter Notebook for data science applications
Python code files are saved with the `.py` extension. You can write and run Python programs
using the command line or by executing scripts within an IDE.
print("Hello, World!")
3. Python Operators
Python uses a variety of operators for performing operations. Here are the major types:
a) Arithmetic Operators
Used to perform mathematical operations:
- + (Addition)
- - (Subtraction)
- * (Multiplication)
- / (Division)
- // (Floor Division)
- % (Modulus)
- ** (Exponentiation)
Example:
a = 10
b=5
print(a + b) # Output: 15
Example:
x = 4 # 0100 in binary
y = 5 # 0101 in binary
print(x & y) # Output: 4
c) Assignment Operators
Used to assign values to variables:
- = (Simple assignment)
- +=, -=, *=, /=, //=, %=, **=
Example:
a = 10
a += 5 # Now a = 15
Example:
a=5 # int
b = 3.2 # float
c = 2 + 3j # complex
b) String Data Type
Used to store text data. Strings are enclosed in single, double, or triple quotes.
Example:
name = "Python"
print(name.upper()) # Output: PYTHON
5. Python Applications
Python is used in a wide variety of fields:
- Web Development – with frameworks like Django, Flask
- Data Science & Machine Learning – using pandas, NumPy, scikit-learn
- Game Development – with PyGame
- Automation/Scripting
- Desktop Applications
- Cybersecurity and Ethical Hacking
6. General Instructions
- Always indent properly in Python (usually 4 spaces). Indentation defines code blocks.
- Use meaningful variable names.
- Save Python files with the `.py` extension.
- Write comments using `#` to explain your code.
- Practice regularly to improve your coding skills.