Python for Beginners (Part 1): From Zero to Writing Your First Programs
Python is one of the most beginner-friendly programming languages in the world. Whether you want to become a data analyst, data scientist, backend developer, automation engineer, or AI engineer, Python is an excellent place to start.
In this first part of the series, you'll learn the fundamentals you need before moving on to decision-making, loops, and functions in Part 2.
Why Learn Python?
Python is known for its simple syntax, making it easy to read and write. It is used in many fields, including:
- Data Analysis
- Artificial Intelligence and Machine Learning
- Web Development
- Automation
- Cybersecurity
- Scientific Computing
If you've never written code before, don't worry. We'll take it one step at a time.
Installing Python
Download the latest version of Python from the official website.
During installation on Windows, remember to check "Add Python to PATH" before clicking Install Now.
To verify your installation, open a terminal and type:
python --version
or
python3 --version
If Python is installed correctly, you'll see the installed version number.
Writing Your First Program
Let's start with the classic program.
print("Hello, World!")
Output:
Hello, World!
Congratulations! You've written your first Python program.
Variables
Variables store information that your program can use later.
name = "Alice"
age = 22
height = 1.68
You can display them using print().
print(name)
print(age)
print(height)
Common Data Types
Python has several built-in data types.
name = "Alice" # String
age = 22 # Integer
height = 1.68 # Float
is_student = True # Boolean
Understanding data types helps you write reliable programs and avoid common mistakes.
Getting User Input
Programs become more useful when they interact with users.
name = input("Enter your name: ")
print("Hello,", name)
Example output:
Enter your name: Victor
Hello, Victor
Basic Operators
Python supports arithmetic operators.
a = 20
b = 5
print(a + b)
print(a - b)
print(a * b)
print(a / b)
You can also calculate remainders using %.
print(20 % 3)
Output:
2
Writing Comments
Comments explain your code and are ignored by Python.
# This is a comment
name = "Alice"
Comments make your code easier for you and others to understand.
Summary
By completing this article, you've learned how to:
- Install Python
- Write your first program
- Create variables
- Work with common data types
- Accept user input
- Perform basic calculations
- Write comments
These are the building blocks you'll use in almost every Python program.
What's Next?
In Part 2, we'll make our programs smarter by learning:
- Comparison operators
-
if,elif, andelse -
forandwhileloops - Functions
- Lists
- Dictionaries
Happy coding, and see you in Part 2!
https://dev.to/victak36lgtm/python-for-beginners-part-2-mastering-python-fundamentals-4i6n
Top comments (0)