Lesson 02 — Python Basics
Lesson 02 — Python Basics
Section titled “Lesson 02 — Python Basics”Lesson Overview
Section titled “Lesson Overview”Python is one of the most popular programming languages in the world.
It powers:
- Cloud Automation
- Artificial Intelligence
- Machine Learning
- Cybersecurity Tools
- DevOps Automation
- Data Science
- APIs
- Web Applications
Python is simple to learn, highly readable, and incredibly powerful, making it the ideal first programming language for IT professionals.
Throughout GoHackersCloud Academy, Python will be used to automate cloud infrastructure, analyze security logs, interact with APIs, build AI applications, and solve real-world problems.
Learning Objectives
Section titled “Learning Objectives”After completing this lesson, you will be able to:
- Install Python.
- Understand the Python interpreter.
- Write your first Python program.
- Learn Python syntax.
- Use comments.
- Display output.
- Accept user input.
- Follow Python coding best practices.
What is Python?
Section titled “What is Python?”Python is a high-level, interpreted programming language created by Guido van Rossum and first released in 1991.
Python is known for:
- Simple syntax
- Readable code
- Large community
- Extensive libraries
- Cross-platform compatibility
It allows developers to solve complex problems using relatively simple code.
Why Python?
Section titled “Why Python?”Python is widely used because it is:
- Easy to learn
- Easy to read
- Open Source
- Cross-platform
- Highly productive
- Extremely versatile
It is often the first programming language taught to students entering Cloud Computing, DevOps, AI, and Cybersecurity.
Python in Modern IT
Section titled “Python in Modern IT”Python is used in many technology domains.
| Domain | Example Use Cases |
|---|---|
| Cloud Computing | AWS & Azure Automation |
| Cybersecurity | Security Tools & Automation |
| DevOps | CI/CD Pipelines |
| Artificial Intelligence | Machine Learning |
| Data Science | Data Analysis |
| Networking | Network Automation |
| Web Development | APIs & Applications |
Learning Python opens opportunities across multiple career paths.
Installing Python
Section titled “Installing Python”Download Python from the official website:
https://python.orgDuring installation:
✔ Install Python
✔ Add Python to PATH
✔ Verify installation
Verifying Installation
Section titled “Verifying Installation”Open Command Prompt or PowerShell.
Run:
python --versionor
python3 --versionExample:
Python 3.13.2This confirms Python is installed successfully.
Python Interpreter
Section titled “Python Interpreter”The Python Interpreter reads and executes Python code line by line.
Python Code
↓
Interpreter
↓
Program OutputUnlike compiled languages, Python executes code immediately.
Starting Python
Section titled “Starting Python”Open a terminal and run:
pythonExample:
>>>The >>> prompt indicates the interactive Python shell.
Exit the interpreter:
exit()or
Ctrl + ZYour First Python Program
Section titled “Your First Python Program”Create a file named:
hello.pyAdd the following code:
print("Hello, GoHackersCloud!")Run:
python hello.pyOutput:
Hello, GoHackersCloud!Congratulations—you’ve written your first Python program!
Understanding print()
Section titled “Understanding print()”The print() function displays information on the screen.
Example:
print("Welcome")Output:
WelcomeMultiple examples:
print("Cloud")
print("Cybersecurity")
print("AI")Output:
Cloud
Cybersecurity
AIPython Syntax
Section titled “Python Syntax”Python uses indentation instead of braces.
Correct:
if True: print("Welcome")Incorrect:
if True:print("Welcome")Indentation is mandatory in Python.
Python is Case Sensitive
Section titled “Python is Case Sensitive”Python treats uppercase and lowercase letters differently.
Correct:
print("Hello")Incorrect:
Print("Hello")print() and Print() are not the same.
Comments
Section titled “Comments”Comments help explain code.
Single-line comment:
# Display welcome message
print("Welcome")Comments are ignored by Python during execution.
Multi-Line Comments
Section titled “Multi-Line Comments”Developers often document code using triple quotes.
Example:
"""This programprints a welcome message."""Documentation improves code readability.
Variables
Section titled “Variables”Variables store information.
Example:
name = "Rohit"
print(name)Output:
RohitVariables make programs dynamic and reusable.
User Input
Section titled “User Input”Programs often need information from users.
Example:
name = input("Enter your name: ")
print("Welcome", name)Output:
Enter your name:
Rahul
Welcome RahulSimple Calculator Example
Section titled “Simple Calculator Example”num1 = int(input("First Number: "))
num2 = int(input("Second Number: "))
print(num1 + num2)Input:
5
10Output:
15Saving Python Files
Section titled “Saving Python Files”Python files use the extension:
.pyExamples:
hello.py
calculator.py
automation.py
aws_script.pyRunning Python Programs
Section titled “Running Python Programs”Command Prompt:
python hello.pyPowerShell:
python hello.pyVS Code Terminal:
python hello.pyThe same script can run on Windows, Linux, and macOS.
Python in VS Code
Section titled “Python in VS Code”Visual Studio Code is one of the best editors for Python.
Typical workflow:
Open VS Code
↓
Create Project Folder
↓
Create .py File
↓
Write Code
↓
Run Program
↓
Debug ErrorsVS Code provides syntax highlighting, debugging, and extensions that improve productivity.
Common Beginner Mistakes
Section titled “Common Beginner Mistakes”Examples include:
- Forgetting quotation marks
- Incorrect indentation
- Misspelled function names
- Missing parentheses
- Incorrect capitalization
- Forgetting to save the file
These mistakes are normal and become less frequent with practice.
Python in Cloud Computing
Section titled “Python in Cloud Computing”Cloud Engineers use Python to:
- Launch AWS resources
- Manage Azure resources
- Automate backups
- Deploy infrastructure
- Monitor cloud services
Python integrates with cloud SDKs such as:
- Boto3 (AWS)
- Azure SDK
- Google Cloud SDK
Python in Cybersecurity
Section titled “Python in Cybersecurity”Security professionals use Python for:
- Log Analysis
- Vulnerability Scanning
- Malware Analysis
- Threat Hunting
- API Automation
- SIEM Integration
- Incident Response
Python is one of the most widely used languages in cybersecurity.
Python in AI
Section titled “Python in AI”Artificial Intelligence developers use Python with libraries such as:
- TensorFlow
- PyTorch
- Scikit-learn
- Pandas
- NumPy
Python dominates the AI ecosystem because of its simplicity and extensive library support.
Best Practices
Section titled “Best Practices”As a beginner Python developer:
- Use meaningful variable names.
- Keep programs simple.
- Practice daily.
- Comment complex logic.
- Read error messages carefully.
- Save files frequently.
- Follow consistent formatting.
- Test your code after every change.
Good habits developed early make programming easier as projects become more complex.
Key Takeaways
Section titled “Key Takeaways”After completing this lesson, you should understand:
- What Python is.
- How to install Python.
- How to run Python programs.
- Python syntax.
- Comments.
- Variables.
- User input.
- Basic Python programming workflow.
Summary
Section titled “Summary”Python is one of the most important programming languages for modern IT professionals.
Its simplicity, readability, and powerful ecosystem make it the preferred language for Cloud Computing, DevOps, Artificial Intelligence, Cybersecurity, and Automation.
By learning Python fundamentals, you’ve taken the first practical step toward building automation scripts, cloud applications, AI solutions, and security tools.
Next Lesson
Section titled “Next Lesson”➡️ Lesson 03 — Python Data Types
In the next lesson, you’ll learn how Python stores different kinds of data using integers, floating-point numbers, strings, booleans, lists, tuples, dictionaries, and sets—the building blocks of every Python application.