Python Introduction
Python was created by Guido van Rossum in 1991 and further developed by the Python Software Foundation. It was designed with focus on code readability and its syntax allows us to express concepts in fewer lines of code.
Key Features of Python
- Python’s simple and readable syntax makes it beginner-friendly.
- Python runs seamlessly on Windows, macOS and Linux.
- Includes libraries for tasks like web development, data analysis and machine learning.
- Variable types are determined automatically at runtime, simplifying code writing.
- Supports multiple programming paradigms, including object-oriented, functional and procedural programming.
- Python is free to use, distribute and modify.
Understanding Hello World Program in Python
Hello, World! in python is the first python program which we learn when we start learning any program. It’s a simple program that displays the message “Hello, World!” on the screen.
Here’s the “Hello World” program:
# This is a comment. It will not be executed.
print("Hello, World!")
Output
Hello, World!
How does this work:
- print() is a built-in Python function that tells the computer to show something on the screen.
- The message “Hello, World!” is a string, which means it’s just text. In Python, strings are always written inside quotes (either single ‘ or double “).
- Anything after # in a line is a comment. Python ignores comments when running the code, but they help people understand what the code is doing.
- Comments are helpful for explaining code, making notes or skipping lines while testing.
We can also write multi-line comments using triple quotes:
"""
This is a multi-line comment.
It can be used to describe larger sections of code.
"""
Indentation in Python
In Python, Indentation is used to define blocks of code. It tells the Python interpreter that a group of statements belongs to a specific block. All statements with the same level of indentation are considered part of the same block. Indentation is achieved using whitespace (spaces or tabs) at the beginning of each line.
Example:
if 10 > 5:
print("This is true!")
print("I am tab indentation")
print("I have no indentation")
Explanation:
- The first two print statements are indented by 4 spaces, so they belong to the if block.
- The third print statement is not indented, so it is outside the if block.
Famous Application Built using Python
- YouTube: World’s largest video-sharing platform uses Python for features like video and backend services.
- Instagram: This popular social media app relies on Python’s simplicity for scaling and handling millions of users.
- : Python is used for backend services and machine learning to personalize music recommendations.
- Dropbox: The file hosting service uses Python for both its desktop client and server-side operations.
- : Python powers key components of ’s recommendation engine and content delivery systems (CDN).
- Google: Python is one of the key languages used in Google for web crawling, testing and data analysis.
- Uber: Python helps Uber handle dynamic pricing and route optimization using machine learning.
- Pinterest: Python is used to process and store huge amounts of image data efficiently.
What can we do with Python?
Python is used for:
- Web Development: Frameworks like Django, Flask.
- Data Science and Analysis: Libraries like Pandas, NumPy, Matplotlib.
- Machine Learning and AI: TensorFlow, PyTorch, Scikit-learn.
- Automation and Scripting: Automate repetitive tasks.
- Game Development: Libraries like Pygame.
- Web Scraping: Tools like BeautifulSoup, Scrapy.
- Desktop Applications: GUI frameworks like Tkinter, PyQt.
- Scientific Computing: SciPy, SymPy.
- Internet of Things (IoT): MicroPython, Raspberry Pi.
- DevOps and Cloud: Automation scripts and APIs.
- Cybersecurity: Penetration testing and ethical hacking tools.