Python Master Class: Beginner 1

Leader posted 3 min read

Python Master Class: Beginner 1

Welcome to your very first step in the world of programming! If you have never written a single line of code before, you are in the exact right place.
Python is one of the most popular, powerful, and beginner-friendly languages on the planet. It reads almost like English, which means you can spend less time stressing over complicated syntax and more time focusing on solving problems and building cool things.

In this introductory guide, we will break down the absolute fundamentals step by step.

1. Hello, World! (Your First Program)

In programming, there is a time-honored tradition that the very first code you write in any language simply prints the words "Hello, World!" to the screen.
In Python, this takes exactly one line:

print("Hello, World!")

How it works:

  • print() is a built-in function in Python that tells the computer to display whatever is inside the parentheses on your screen.
  • The quotation marks "" tell Python that the text inside is a string (a sequence of characters/text), not a command.

    2. Variables: The Storage Boxes of Code

    Imagine you are packing for a move and you put your books inside a cardboard box. You write "Books" on the outside of the box so you know what's inside.
    In Python, a variable is exactly like that labeled box. It is a reserved spot in the computer's memory where you can store data, and you give it a name so you can find it later.
    Here is how you create and use a variable:

    # Storing data in a box called "playerName"
    playerName = "Alex"
    # Storing a number in a box called "score"
    score = 100
    # Using the variables
    print(playerName)
    print(score)
    

    > Note: The lines starting with a hashtag (#) are comments. Python completely ignores them. They are just notes written by programmers to explain what the code does!

    3. Basic Data Types

    Data comes in different flavors. Python automatically detects what kind of data you are storing, but you need to know the three most common basic types:

    1. Strings (str)

    Textual data enclosed in single or double quotes.

    greeting = "Welcome to the game!"
    

    2. Integers (int)

    Whole numbers (positive, negative, or zero) without any decimals.

    age = 14
    temperature = -3
    

    3. Floats (float)

    Numbers that contain decimal points.

    pi = 3.1415
    price = 99.95
    

    4. Doing Math in Python

    Python is an excellent calculator. You can use standard symbols to perform arithmetic operations on numbers.

Operation Operator Example Result
Addition + 5 + 3 8
Subtraction - 10 - 4 6
Multiplication * 4 * 2 8
Division / 10 / 2 5.0 (Always gives a float)

You can also use variables in your math equations:

cookies_in_box = 12
eaten_cookies = 3
remaining_cookies = cookies_in_box - eaten_cookies
print(remaining_cookies)  # This will print 9

5. Making Decisions (If/Else Statements)

A huge part of programming involves making decisions. "If this happens, do Option A; otherwise, do Option B."
In Python, we use if and else statements to guide the flow of our program.

score = 85
if score >= 50:
    print("Congratulations! You passed.")
else:
    print("Don't give up! Try again.")

Crucial Python Rule: Indentation

Notice the blank space before the print statements? That is called indentation (usually created by hitting the Tab key once or Spacebar four times).

Unlike other languages, Python requires this spacing to know which lines of code belong inside the if or else sections. If you leave it out, Python will throw an error!

Next Steps

Congratulations! You've just learned the core pillars of Python: printing, variables, data types, basic math, and decision-making.
To practice, try installing Python on your computer (or use an online Python interpreter like Replit), type out these code blocks, and change the numbers or text to see what happens. Happy coding!

Part 1 of 1 in Python Master Class
3.3k Points74 Badges1 13 60
30Posts
37Comments
8Followers
9Connections
I like coding and working with different micro controllers
Build your own developer journey
Track progress. Share learning. Stay consistent.
🔥 Join developers growing publicly
Share your knowledge, build in public, and grow your developer presence with a global community.

More Posts

Dashboard Operasional Armada Rental Mobil dengan Python + FastAPI

Masbadar - Mar 12

I Wrote a Script to Fix Audible's Unreadable PDF Filenames

snapsynapseverified - Apr 20

Python for Absolute Beginners: From Zero to Writing Real Code

Prasoon Jadon - Feb 21

Forecast Kebutuhan Bahan & Produksi Konveksi dengan Python (Praktis + Template)

Masbadar - Mar 8

Python in data analytics: a beginners guide

brian - May 14
chevron_left

Related Jobs

View all jobs →

Commenters (This Week)

3 comments
2 comments
1 comment

Contribute meaningful comments to climb the leaderboard and earn badges!