My First Steps in Python: From Hello World to if/else/elif

When I first began learning programming, I chose Python because of its simple syntax and readability. It felt welcoming, especially for someone coming from a non-technical background. My goal was to understand the core logic behind programming and be able to communicate with a machine through code.

Starting with the Basics

I began by learning how to output text to the screen using print(). This simple command taught me how programs provide feedback. Then I explored variables — how to store and reuse data — and understood how types like strings, integers, and booleans work.

My First Python Commands

Here are the fundamental Python concepts I learned first:

Python Basics - Variables and Typespython
1# My first Python commands
2print("Hello, world!")
3
4# Variables and data types
5x = 10                    # Integer
6name = "Nikolas"         # String
7is_learning = True       # Boolean
8temperature = 23.5       # Float
9
10# Basic operators
11result = x + 5           # Addition: 15
12greeting = "Hello, " + name    # String concatenation
13is_adult = x >= 18       # Comparison: False
14
15# User input
16user_name = input("What's your name? ")
17print(f"Nice to meet you, {user_name}!")
  • Printing: print("Hello, world!") - my very first command!
  • Variables: x = 10, name = "Nikolas" - storing data
  • Types: Strings, integers, booleans, floats - Python figures them out automatically
  • Operators: +, -, *, /, ==, != - doing math and comparisons
  • User input: input() - making programs interactive

Controlling Logic with Conditions

One of the biggest breakthroughs for me was learning how to make the computer "decide" something based on conditions. This is where if, elif, and else come into play.

Conditional Logic Examplepython
1# Simple age checker program
2age = 18
3
4if age >= 18:
5    print("You are an adult.")
6    print("You can vote!")
7elif age >= 13:
8    print("You are a teenager.")
9    print("Almost there!")
10else:
11    print("You are a child.")
12    print("Enjoy being young!")
13
14# More complex example
15user_age = int(input("How old are you? "))
16has_license = input("Do you have a license? (yes/no): ").lower()
17
18if user_age >= 18 and has_license == "yes":
19    print("You can drive legally!")
20elif user_age >= 18 and has_license == "no":
21    print("You're old enough, but you need a license.")
22elif user_age >= 16:
23    print("You can get a learner's permit!")
24else:
25    print("You're too young to drive.")

This structure gave me control over how a program should respond. It felt like having a conversation with the computer — giving it choices and instructing it on what to do next.

Practice Makes Perfect

To really understand conditionals, I wrote several small programs:

My Practice Programspython
1# Program 1: Grade calculator
2score = float(input("Enter your test score: "))
3
4if score >= 90:
5    grade = "A"
6elif score >= 80:
7    grade = "B"
8elif score >= 70:
9    grade = "C"
10elif score >= 60:
11    grade = "D"
12else:
13    grade = "F"
14
15print(f"Your grade is: {grade}")
16
17# Program 2: Weather advice
18weather = input("How's the weather? (sunny/rainy/cold): ").lower()
19
20if weather == "sunny":
21    print("Wear sunglasses and light clothes!")
22elif weather == "rainy":
23    print("Don't forget your umbrella!")
24elif weather == "cold":
25    print("Bundle up with a warm jacket!")
26else:
27    print("I'm not sure about that weather...")
28
29# Program 3: Simple password checker
30correct_password = "python123"
31user_password = input("Enter password: ")
32
33if user_password == correct_password:
34    print("Access granted! Welcome!")
35else:
36    print("Access denied. Wrong password.")

Key Insights and Realizations

  • Conditional logic is the foundation of programming logic - it's everywhere!
  • Even simple programs can become powerful when you add choices and decision-making.
  • Learning the difference between = (assignment) and == (comparison) was crucial!
  • Indentation matters in Python - it's not just for looks, it's part of the syntax.
  • The elif statement is a game-changer for handling multiple conditions elegantly.
  • Combining conditions with and, or, and not opens up endless possibilities.

What I'm Looking Forward To

With conditions mastered, I'm excited to dive into loops (for, while), which will allow me to automate tasks and repeat actions efficiently. I'll also start exploring data structures like lists and dictionaries to manage collections of data.

What I'm Learning Nextpython
1# Coming up in my Python journey:
2
3# Loops - for repetitive tasks
4for i in range(5):
5    print(f"This is iteration {i}")
6
7# Lists - storing multiple items
8my_favorite_languages = ["Python", "JavaScript", "CSS"]
9
10# Functions - organizing code into reusable blocks
11def greet_user(name):
12    return f"Hello, {name}! Welcome to Python!"
13
14# I can't wait to learn these concepts!

Every small script I write builds my confidence. Python has made the entry into programming incredibly smooth, and I can now begin thinking about real-world applications — from automation to building tools and websites.

"Programming in Python is like learning a new language — the more I practice, the more fluent I become."

💬 Comments & Discussion

Share your thoughts, ask questions, or discuss this post. Comments are powered by GitHub Discussions.