Subject: Computer Science
Topic: Introduction to Python Programming Language
Name: ___________________
Class: ________ Roll Number: ________ Section: ________
Python – Introduction to Programming Language
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.
Example of a simple Python program:
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
b) Binary Operators (Bitwise Operators)
Used to perform operations on binary numbers:
- & (AND)
- | (OR)
- ^ (XOR)
- ~ (NOT)
- << (Left Shift)
- >> (Right Shift)
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
4. Data Types in Python
Python supports various data types, but two basic types are numeric and string.
a) Numeric Data Types
- int (e.g., 10, -3)
- float (e.g., 3.14, -0.5)
- complex (e.g., 2 + 3j)
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.