Back to Engineering
24 APRIL 2026

Python for Beginners: A Practical Introduction to Python Coding

CA
Compiled by Cypher Async

Why Python Is the Best First Language

Python is consistently the most popular language for beginners — and for good reason. Its syntax reads almost like plain English, there's no boilerplate to fight, and it runs everywhere.

Compare how you'd print "Hello" in three languages:

// Java — verbose, strict
public class Main {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
    }
}
// C — manual memory, complex syntax
#include <stdio.h>
int main() {
    printf("Hello, World!\n");
    return 0;
}
# Python — just say what you mean
print("Hello, World!")

Python lets beginners focus on thinking like a programmer, not fighting syntax.


Setting Up

Download Python from python.org. Once installed, open your terminal:

python3 --version
# Python 3.12.0

To run a file:

python3 my_program.py

Or use the interactive shell for quick experiments:

python3
>>> 2 + 2
4
>>> print("Hello!")
Hello!

1. Variables and Data Types

Variables store data. Python figures out the type automatically:

name       = "Aryan"    # str  — text
age        = 17         # int  — whole number
gpa        = 9.2        # float — decimal
is_enrolled = True      # bool — True or False

print(type(name))        # <class 'str'>
print(type(age))         # <class 'int'>
print(type(is_enrolled)) # <class 'bool'>

How Python stores a variable in memory:

  Variable name        Memory
  ─────────────        ──────────────────────
  name          ──►    [ "Aryan"            ]
  age           ──►    [ 17                 ]
  gpa           ──►    [ 9.2                ]
  is_enrolled   ──►    [ True               ]

2. String Operations

Strings are text. You can slice, join, and format them:

name = "Cypher Async"

print(name.upper())         # CYPHER ASYNC
print(name.lower())         # cypher async
print(name[0:6])            # Cypher   (slice from index 0 to 5)
print(len(name))            # 12       (length)
print("Async" in name)      # True     (check if substring exists)

# f-strings: the cleanest way to embed variables in text
school = "Cypher Async"
city   = "Agartala"
print(f"{school} is based in {city}.")
# Cypher Async is based in Agartala.

3. Taking Input from the User

name  = input("What is your name? ")
age   = int(input("How old are you? "))   # input() always returns a string — cast to int

print(f"Hello, {name}! You are {age} years old.")
print(f"In 5 years you will be {age + 5}.")

Flow of an input/output program:

  Program starts
       │
       ▼
  Show prompt ──► "What is your name?"
       │
       ▼
  Wait for user to type
       │
       ▼
  Store input in variable
       │
       ▼
  Use the variable in output
       │
       ▼
  Program ends

4. Conditional Statements

marks = 85

if marks >= 90:
    print("Grade: A+")
elif marks >= 75:
    print("Grade: A")
elif marks >= 60:
    print("Grade: B")
else:
    print("Needs improvement")

# Output: Grade: A

Decision flowchart for the above code:

  marks = 85
      │
      ▼
  marks >= 90? ──► YES ──► Print "A+"
      │
      NO
      │
      ▼
  marks >= 75? ──► YES ──► Print "A"    ◄── We land here
      │
      NO
      │
      ▼
  marks >= 60? ──► YES ──► Print "B"
      │
      NO
      │
      ▼
  Print "Needs improvement"

5. Loops

For loop — repeat over a sequence:

fruits = ["mango", "banana", "apple", "grape"]

for fruit in fruits:
    print(f"I like {fruit}")

# I like mango
# I like banana
# I like apple
# I like grape

While loop — repeat until a condition is false:

count = 1

while count <= 5:
    print(f"Count: {count}")
    count += 1

# Count: 1
# Count: 2
# Count: 3
# Count: 4
# Count: 5

Loop execution diagram:

  FOR LOOP                          WHILE LOOP
  ────────                          ──────────

  Start with list                   Set count = 1
       │                                 │
       ▼                                 ▼
  Any items left? ──NO──► Done     count <= 5? ──NO──► Done
       │                                 │
      YES                               YES
       │                                 │
       ▼                                 ▼
  Take next item                    Run the block
       │                                 │
       ▼                                 ▼
  Run the block                     count += 1
       │                                 │
       └──────────────────────────────── ┘
             (back to top)

6. Functions

Functions let you name and reuse a block of code:

def calculate_grade(marks):
    if marks >= 90:
        return "A+"
    elif marks >= 75:
        return "A"
    elif marks >= 60:
        return "B"
    else:
        return "C"

# Call it as many times as you like
print(calculate_grade(95))   # A+
print(calculate_grade(82))   # A
print(calculate_grade(55))   # C

How a function call works:

  Main program                     Function
  ────────────                     ────────
  calculate_grade(82)  ──────►    marks = 82
                                       │
                                       ▼
                                  Run logic
                                       │
                                       ▼
  receives "A"         ◄──────    return "A"

7. Lists

A list holds multiple values in order:

students = ["Priya", "Rohan", "Anika", "Dev"]

print(students[0])       # Priya      (index starts at 0)
print(students[-1])      # Dev        (last item)
print(len(students))     # 4

students.append("Zara")  # add to end
students.remove("Rohan") # remove by value

for student in students:
    print(student)

List index diagram:

  students = ["Priya", "Rohan", "Anika", "Dev"]
               ───────  ───────  ───────  ─────
  Index:          0        1        2       3
  Reverse:       -4       -3       -2      -1

8. Dictionaries

Key-value pairs — perfect for structured data:

student = {
    "name":    "Rohan",
    "age":     16,
    "city":    "Agartala",
    "enrolled": True
}

print(student["name"])     # Rohan
print(student["city"])     # Agartala

student["grade"] = "A"     # add a new key
print(student)
# {'name': 'Rohan', 'age': 16, 'city': 'Agartala', 'enrolled': True, 'grade': 'A'}

A Complete Mini Project

Putting it all together — a simple student grade calculator:

def get_grade(marks):
    if marks >= 90:
        return "A+"
    elif marks >= 75:
        return "A"
    elif marks >= 60:
        return "B"
    else:
        return "C"

students = []
count = int(input("How many students? "))

for i in range(count):
    name  = input(f"Student {i + 1} name: ")
    marks = int(input(f"Marks for {name}: "))
    students.append({"name": name, "marks": marks, "grade": get_grade(marks)})

print("\n--- Results ---")
for s in students:
    print(f"{s['name']}: {s['marks']} marks → Grade {s['grade']}")

Sample run:

How many students? 3
Student 1 name: Priya
Marks for Priya: 92
Student 2 name: Rohan
Marks for Rohan: 78
Student 3 name: Anika
Marks for Anika: 55

--- Results ---
Priya: 92 marks → Grade A+
Rohan: 78 marks → Grade A
Anika: 55 marks → Grade C

What Next?

Once you're comfortable with these basics, explore:

  • File handling — reading and writing .txt and .csv files
  • Modulesmath, random, datetime, os
  • Object-Oriented Programming — classes, objects, inheritance
  • Librariesrequests for APIs, pandas for data, flask for web apps

Practice Makes Permanent

The biggest mistake beginners make is reading too much and coding too little. Write code every day — even if it's 10 lines. Break things. Fix them. That's how you learn Python.


At Cypher Async, our Python courses go from zero to project-ready in a structured, offline classroom setting. If you're in Agartala and want to start coding seriously, we'd love to have you.