Python Programming Tutorial for Absolute Beginners | Darchums Technologies

 Introduction:

Welcome to Darchums Technologies! In this tutorial, we’re diving into the world of Python — one of the most powerful, beginner-friendly, and in-demand programming languages today. Whether you're just getting started or need a refresher, this tutorial will guide you step-by-step with real examples.


Why Learn Python?

  • Easy to read and write

  • Versatile: Web dev, AI, Data Science, Games, Automation

  • Huge community and libraries 

1. Setting Up Python

Step 1: Download Python from python.org
Step 2: Install it and tick “Add Python to PATH”
Step 3: Open your terminal or IDLE (comes with Python)
To confirm installation:

>>> python --version


2. Your First Python Program

Create a file named hello.py and add:

print ("Hello, world!")

Run it: 

python hello.py

(This will output, Hello, world!)

Kudos! You've just written your first program. 


3. Variables and Data Types


name = "Darchums"
age = 25
height = 5.9
is_coder = True

Use type () to check:
print(type(age))   # <class 'int'>

4. Basic Operations

# Math
print (10 + 5)   output 15
print (10 / 2)     output 5

# Strings
greeting = "Hello" + " " + name
print (greeting)   
output Hello Darchums!

🧠 Explanation:

  • "Hello" is a string.

  • " " is a space.

  • name contains "Darchums".

  • When you use the + operator with strings, it joins them together (this is called string concatenation).


5. Control Flow (if/else)


if age > 18:
    print ("You are an adult.")
else:
    print ("You are a minor.") output: (You are an adult.)


🧠 Explanation:

  • age = 25 → This assigns the value 25 to the variable age.

  • The condition age > 18 is True, since 25 is greater than 18.

  • Therefore, the code inside the if block runs: print("You are an adult.")

  • The else block is ignored because the condition was already satisfied.

If you change age = 15, the output would then be:

("you are a minor")


6. Loops

# For loop
for i in range(5):
    print(i)

# While loop
count = 0
while count < 3:
    print("Counting:", count)
    count += 1


7. Functions

def greet(user):
    print (f"Welcome, {user}!")

greet("Darchums") 

Output:  Welcome,  Darchums!


8. Lists and Dictionaries


# List
fruits = ["apple", "banana", "cherry"]
print(fruits[1])

Output: banana

🧠 Explanation:

  • Lists in Python are zero-indexed, which means:

    • fruits[0]"apple"

    • fruits[1]"banana"

    • fruits[2]"cherry"

So print(fruits[1]) prints "banana


# Dictionary
user = {"name": "Darlington", "age": 30}
print(user["name"])

Output: Darlington

🧠 Explanation:

  • A dictionary stores data in key-value pairs.

  • "name" is a key, and its value is "Darlington".

  • So user["name"] retrieves and prints that value.


9. Errors and Debugging


try:
    print(10 / 0)
except ZeroDivisionError:
    print ("Cannot divide by zero.")

Output:  Cannot divide by zero.

🧠 Explanation:
  • 10 / 0 would normally cause a ZeroDivisionError, because you can't divide a number by zero.

  • But since it's inside a try block, Python doesn't crash. Instead, it jumps to the except block.

  • The message "Cannot divide by zero." is printed instead.


10. Final Project: Simple Calculator


def calculator():
    a = float(input("Enter first number: "))
    b = float(input("Enter second number: "))
    op = input("Choose operation (+, -, *, /): ")

    if op == '+':
        print(a + b)
    elif op == '-':
        print(a - b)
    elif op == '*':
        print(a * b)
    elif op == '/':
        if b != 0:
            print(a / b)
        else:
            print("Error: Division by zero.")
    else:
        print("Invalid operator.")

calculator()



Conclusion

Now you’ve made your first steps in Python! Practice every day, experiment, and don’t fear errors — they are part of learning.
Stay tuned for more in-depth tutorials right here on Darchums Technologies! -Learn, Code, Create.













Comments