Resources / Coding
Free to readCoding⏱ 6 min read

Programming basics for absolute beginners

Never coded before? Learn variables, conditions, loops, functions and lists in plain English, with tiny Python examples and exercises.

What a program is

A program is a list of instructions the computer follows one by one. You write them in a programming language (we use Python here because it reads almost like English), and the computer runs them.

💡 Tip

You can run every example on this page in a free online Python editor — no installation needed.

1. Printing

Python
print("Hello, ManiaJobs!")
▶ Output
Hello, ManiaJobs!

Shows the text on the screen. Text always goes inside quotes.

2. Variables — boxes with names

📖 Variable and data type

Definition: A variable is a name bound to a value stored in memory; a data type defines what kind of value it is and which operations are allowed on it.

How it works: Python is dynamically typed (the type belongs to the value, checked at run time) and strongly typed (it won't silently mix incompatible types like "5" + 3). Built-in types: int, float, str, bool, list, tuple, dict, set, None.

Example: age = 21 binds the name age to an int object; type(age) → <class 'int'>.

🧒 In simple words

Python
name = "Asha"
age = 21
cgpa = 8.4
print(name, "is", age)
▶ Output
Asha is 21

A variable stores a value so you can use it later. = means "put this value in the box".

TypeExampleUsed for
int21whole numbers
float8.4decimals
str"Asha"text
boolTrue / Falseyes/no

3. Input and maths

Python
a = int(input("First number: "))
b = int(input("Second number: "))
print("Sum:", a + b)
▶ Output
First number: 4
Second number: 5
Sum: 9

input() always gives text, so int() turns it into a number. Operators: + - * /, // (whole division), % (remainder), ** (power).

4. Conditions — making decisions

📖 Conditional statements

Definition: Conditional statements execute different blocks of code depending on whether a Boolean condition is true.

How it works: if checks the first condition, elif checks further ones only if previous ones were false, and else runs when none matched. Python uses indentation to mark blocks.

Example: If marks ≥ 75 print "Distinction", elif ≥ 60 "First class", else "Keep going".

🧒 In simple words

Python
marks = 72
if marks >= 75:
    print("Distinction")
elif marks >= 60:
    print("First class")
else:
    print("Keep going!")
▶ Output
First class

Python uses indentation (4 spaces) to know which lines belong to the if.

5. Loops — repeat work

📖 Loops

Definition: A loop repeatedly executes a block of code: a for loop iterates over each item of an iterable, a while loop repeats while a condition stays true.

How it works: range(start, stop, step) produces numbers for counting loops. break exits the loop early, continue skips to the next iteration. Avoid infinite while loops by changing the condition inside.

Example: Adding every order amount in a list to a running total.

🧒 In simple words

Python
for i in range(1, 6):
    print(i)        # 1 2 3 4 5

count = 3
while count > 0:
    print(count)
    count = count - 1
▶ Output
1
2
3
4
5
3
2
1

Use for when you know how many times, while when you repeat until something changes.

6. Lists — many values in one variable

📖 List

Definition: A list is an ordered, mutable collection that can hold items of any type, accessed by zero-based index.

How it works: Supports indexing a[0], slicing a[1:3], append, insert, pop, sort. Appending is amortised O(1); searching with in is O(n).

Example: marks = [78, 91, 65]; marks.append(88).

🧒 In simple words

Python
marks = [78, 91, 65, 88]
print(marks[0])      # 78 (counting starts at 0)
marks.append(70)
print(len(marks), max(marks), sum(marks) / len(marks))
▶ Output
78
5 91 78.4

7. Functions — reusable blocks

📖 Function

Definition: A function is a named, reusable block of code that takes inputs (parameters), performs a task and optionally returns a result.

How it works: Defined with def. Parameters can have default values and be passed by keyword. Variables created inside a function are local. Functions are first-class objects, so they can be passed to other functions.

Example: def bill(amount, gst=0.05): return amount * (1 + gst).

🧒 In simple words

Python
def grade(m):
    if m >= 90: return "A"
    if m >= 75: return "B"
    return "C"

print(grade(88))     # B
▶ Output
B

A function takes inputs (parameters), does a job and returns a result.

8. Dictionaries — look things up by name

📖 Dictionary

Definition: A dictionary is a mutable mapping of unique, hashable keys to values, implemented as a hash table.

How it works: Lookup, insert and delete are average O(1). Keys are usually strings or numbers; values can be anything. Since Python 3.7 dictionaries keep insertion order. JSON objects map directly to dicts.

Example: student = {"name": "Ravi", "cgpa": 8.1}; student["cgpa"] → 8.1.

🧒 In simple words

Python
student = {"name": "Ravi", "branch": "ECE", "cgpa": 8.1}
print(student["branch"])
student["city"] = "Vizag"
▶ Output
ECE

9. Thinking like a programmer

  1. Understand the problem with one small example.
  2. Write the steps in plain English first.
  3. Turn each step into code.
  4. Test with normal, empty and extreme inputs.
  5. Fix one error at a time — read the error message, it tells you the line.

Exercises (answers below)

  1. Print your name 5 times.
  2. Ask for a number and say if it is even or odd.
  3. Print the multiplication table of 7.
  4. Find the largest of three numbers.
  5. Add all numbers from 1 to 100.
  6. Count the vowels in a word.
  7. Reverse a string.
  8. Write a function that checks if a number is prime.

Answers

  1. for i in range(5): print("Asha")
  2. n = int(input()); print("even" if n % 2 == 0 else "odd")
  3. for i in range(1, 11): print(7, "x", i, "=", 7 * i)
  4. print(max(a, b, c))
  5. print(sum(range(1, 101))) → 5050
  6. print(sum(1 for ch in word.lower() if ch in "aeiou"))
  7. print(word[::-1])
  8. def is_prime(n): return n > 1 and all(n % d for d in range(2, int(n ** 0.5) + 1))

What to learn next

Once these feel easy: strings in depth → files → object-oriented programming (classes) → data structures (stack, queue, linked list) → our coding interview patterns plan.

Further reading

🔥Join the free 30-Day Placement ChallengeOne resource and one task a day — from resume to offer.