Reference library · For Aetheris students

Programming
reference.

A small, curated library of Java and Python snippets — for revising syntax, recognising patterns, and practising the methods we work through in class.

Python · 01

Input, output, and variables

The first reference for any basic Python program — read a value, compare it, and print a result.

python · grade_calculator.py

name = input("Enter student name: ")
marks = float(input("Enter marks: "))

if marks >= 90:
    grade = "A"
elif marks >= 75:
    grade = "B"
elif marks >= 60:
    grade = "C"
else:
    grade = "Needs improvement"

print(name, "received grade", grade)

Python · 02

Loops

Examples for repetition, counting, and simple logic building.

python · multiplication_table.py

number = int(input("Enter a number: "))

print(f"Multiplication table for {number}:")
for i in range(1, 11):
    print(f"{number} x {i} = {number * i}")

Python · 03

Functions

Defining reusable behaviour, handling empty input, and returning a value with type-aware formatting.

python · average.py

def calculate_average(marks):
    """Return the average of a list of marks."""
    if not marks:
        return 0
    return sum(marks) / len(marks)


student_marks = [78, 84, 91, 67, 72]
average = calculate_average(student_marks)
print(f"Average: {average:.2f}")

Java · 04

Basics

Java's familiar "Hello, name!" — a class, a main method, a string, and a print.

java · Greeting.java

public class Greeting {
    public static void main(String[] args) {
        String name = "Aetheris";
        System.out.println("Hello, " + name + "!");
    }
}

Java · 05

Loops

A classic for loop printing the multiplication table — line-by-line, with string concatenation.

java · Multiplier.java

public class Multiplier {
    public static void main(String[] args) {
        int number = 7;
        for (int i = 1; i <= 10; i++) {
            System.out.println(number + " x " + i + " = " + (number * i));
        }
    }
}

Java · 06

Classes

Encapsulating data and behaviour: a Student class with a constructor and a method.

java · Student.java

public class Student {
    private String name;
    private int grade;

    public Student(String name, int grade) {
        this.name = name;
        this.grade = grade;
    }

    public String describe() {
        return name + " is in grade " + grade;
    }

    public static void main(String[] args) {
        Student s = new Student("Aisha", 10);
        System.out.println(s.describe());
    }
}