Skip to content
AgileLogics
Beginner 5 min read

Beginner Projects

Prerequisites: Level 1 — Beginner

Build these with nothing but what Level 1 covered — print, readLine, constants and variables, optionals, conditionals, loops, arrays, dictionaries, functions, and closures. Each one fits in a single .swift file you run with swift main.swift.

1. Command-Line Calculator

Read two numbers and an operator (+ - * /) with readLine(), convert them with Double(...), and print the result using a switch. Handle input that isn't a number, an unknown operator, and division by zero with clear messages instead of crashing.

Hint: Double("abc") returns nil — use guard let to handle it.

2. Number Guessing Game

Pick a secret number with Int.random(in: 1...100), then loop, reading guesses and printing "Too high" or "Too low" until the player gets it right. Count and print the attempts.

3. To-Do List

Keep tasks in an array of tuples like (title: String, done: Bool). Loop over a menu (add / list / done / quit) handled with switch, and use enumerated() to print numbered tasks with a [x] or [ ] marker.

4. Unit Converter

Store conversion factors in a dictionary (["km→mi": 0.621371, ...]), list the options sorted by name, and convert the number the user enters.

5. Password Generator

Ask for a length, then build a password by picking random characters from a string of letters, digits, and symbols with randomElement(). Refuse lengths under 8.

6. Simple Quiz

Store questions and answers in an array of tuples, ask each one, compare answers ignoring case with lowercased(), and print a final score like You scored 4/5.

7. Grade Book

Store student names and scores in a [String: [Int]] dictionary. Write functions that return each student's average and the top student, and print a report with the names in alphabetical order.