# assignments.all()

Assignments

Every practice challenge across the twelve modules. Click through to attempt in the live editor.

MODULE_01 // INTRODUCTION TO COMPUTERS, PROGRAMMING & PYTHON INSTALLATIONOPEN →
  1. // CHALLENGE_1

    Welcome to your first Python coding challenge! Your goal is to write a script that outputs two friendly welcome lines.

    Steps to Complete:

    1. Use a print() statement to output Hello, World! on the first line.
    2. Use a second print() statement to output Welcome to Python Programming! on the second line.

    Input: None

    Expected Output:

    TEXT
  2. // CHALLENGE_2

    Let's build a 3-line welcome banner that calculates hours automatically!

    Steps to Complete:

    1. Print Python Studio v1.0 on line 1.
    2. Print Total Modules: 12 on line 2.
    3. Print Estimated Hours: 9 on line 3, calculating the number 9 using integer division math directly inside your print() statement: 12 * 45 // 60.

    Input: None

    Expected Output:

    TEXT
  3. // CHALLENGE_3

    Let's create a deployment status card for a server service!

    Steps to Complete:

    1. Create variables nodes = 4 and limit = 100.
    2. Print Service: Auth-Service on line 1.
    3. Print Active Nodes: 4 on line 2.
    4. Print Total Capacity: 400 on line 3, calculating 400 by multiplying nodes * limit inside your print() statement.

    Input: None

    Expected Output:

    TEXT
MODULE_02 // VARIABLES, DATA TYPES & BASIC OPERATIONSOPEN →
  1. // CHALLENGE_1

    Let's practice rectangle geometry using Python variables!

    Steps to Complete:

    1. Create two variables: width = 15 and height = 8.
    2. Calculate the area (width * height) and print Area: 120.
    3. Calculate the perimeter (2 * (width + height)) and print Perimeter: 46.

    Input: None

    Expected Output:

    TEXT
  2. // CHALLENGE_2

    Let's build a formatted score card message for a user!

    Steps to Complete:

    1. Define variables user_name = 'DevUser' and score = 94.5.
    2. Print a single formatted line inserting these variables: User DevUser achieved a score of 94.5%.

    Input: user_name = 'DevUser', score = 94.5

    Expected Output:

    TEXT
  3. // CHALLENGE_3

    Let me help you calculate system uptime percentage!

    Steps to Complete:

    1. Define total_hours = 720 and downtime_hours = 1.8.
    2. Print Total Hours: 720.
    3. Calculate uptime percentage as ((total_hours - downtime_hours) / total_hours) * 100 and print Uptime: 99.75%.

    Input: None

    Expected Output:

    TEXT
MODULE_03 // STRINGS & CONDITIONAL STATEMENTSOPEN →
  1. // CHALLENGE_1

    Warm-up 1: Print the first and last character of a string.

    Steps:

    1. Set word = "Developer".
    2. Print First: D.
    3. Print Last: r.
  2. // CHALLENGE_2

    Warm-up 2: Check if a number is positive.

    Steps:

    1. Given num = 42.
    2. If num > 0, print Positive number.
  3. // CHALLENGE_3

    Warm-up 3: Convert text to uppercase and slice the first 3 letters.

    Steps:

    1. Given code = "python".
    2. Uppercase the string and slice first 3 characters.
    3. Print Prefix: PYT.
  4. // CHALLENGE_4

    Apply-it 1: Grade evaluator using if-elif-else.

    Steps:

    1. Given score = 88.
    2. If score >= 90 print Grade: A.
    3. Else if score >= 80 print Grade: B.
    4. Else print Grade: C.
  5. // CHALLENGE_5

    Apply-it 2: Password strength checker.

    Steps:

    1. Given password = "secret123".
    2. If length >= 8 AND contains numbers (check any(char.isdigit() for char in password)), print Strong Password.
    3. Otherwise print Weak Password.
  6. // CHALLENGE_6

    Apply-it 3: Text cleaning and word count check.

    Steps:

    1. Given raw_text = " Python programming is fun! ".
    2. Strip surrounding whitespace using .strip().
    3. Print Cleaned: Python programming is fun!.
    4. If length > 10, print Long sentence.
  7. // CHALLENGE_7

    Stretch Challenge: Discount Ticket Calculator.

    Steps:

    1. Given age = 65 and is_student = False.
    2. If age <= 12 or age >= 60 or is_student, ticket price is 10.
    3. Otherwise ticket price is 20.
    4. Print Ticket Price: $10.
MODULE_04 // LISTS & TUPLESOPEN →
  1. // CHALLENGE_1

    Warm-up 1: Create a list of 3 colors and print the second color.

    Steps:

    1. Define colors = ["red", "green", "blue"].
    2. Print Second: green.
  2. // CHALLENGE_2

    Warm-up 2: Append and remove from a list.

    Steps:

    1. Start with nums = [10, 20].
    2. Append 30.
    3. Pop the last item.
    4. Print Final: [10, 20].
  3. // CHALLENGE_3

    Warm-up 3: Unpack a tuple.

    Steps:

    1. Given point = (5, 10).
    2. Unpack into x, y.
    3. Print X: 5, Y: 10.
  4. // CHALLENGE_4

    Apply-it 1: Sort a list of high scores.

    Steps:

    1. Given scores = [45, 92, 12, 78].
    2. Sort list in ascending order using .sort().
    3. Print Sorted: [12, 45, 78, 92].
  5. // CHALLENGE_5

    Apply-it 2: Check item membership in guest list.

    Steps:

    1. Given guests = ["Alice", "Bob", "Charlie"].
    2. If "Bob" is in guests, print Bob is invited!.
  6. // CHALLENGE_6

    Apply-it 3: Slice top 3 leaderboard spots.

    Steps:

    1. Given players = ["Sam", "Alex", "Jordan", "Taylor", "Morgan"].
    2. Slice top 3 players into top_three.
    3. Print Podium: ['Sam', 'Alex', 'Jordan'].
  7. // CHALLENGE_7

    Stretch Challenge: Inventory tracker update.

    Steps:

    1. Start with inventory = ["laptop", "mouse"].
    2. Add "keyboard".
    3. Replace "mouse" at index 1 with "trackpad".
    4. Print Inventory: ['laptop', 'trackpad', 'keyboard'].
MODULE_05 // DICTIONARIES & SETSOPEN →
  1. // CHALLENGE_1

    Warm-up 1: Create a dictionary for a product and print its price.

    Steps:

    1. Define product = {"item": "Laptop", "price": 999}.
    2. Print Price: $999.
  2. // CHALLENGE_2

    Warm-up 2: Remove duplicates using a set.

    Steps:

    1. Given raw_ids = [101, 102, 101, 103, 102].
    2. Convert to set to remove duplicates.
    3. Print unique count: Unique IDs: 3.
  3. // CHALLENGE_3

    Warm-up 3: Safe dictionary lookup using .get().

    Steps:

    1. Given config = {"theme": "dark"}.
    2. Fetch "fontSize" with default 14.
    3. Print Font Size: 14.
  4. // CHALLENGE_4

    Apply-it 1: Update and add dictionary keys.

    Steps:

    1. Given car = {"brand": "Tesla", "year": 2022}.
    2. Update year to 2024.
    3. Add color as "Red".
    4. Print Updated Car: {'brand': 'Tesla', 'year': 2024, 'color': 'Red'}.
  5. // CHALLENGE_5

    Apply-it 2: Find common items in two sets.

    Steps:

    1. Given club_a = {"Alice", "Bob", "Charlie"} and club_b = {"Bob", "David", "Alice"}.
    2. Find intersection of members in both clubs.
    3. Check if "Alice" is in both. Print Both in clubs: True.
  6. // CHALLENGE_6

    Apply-it 3: Iterate over dictionary keys and values.

    Steps:

    1. Given scores = {"Math": 90, "Science": 85}.
    2. Print total score: Total Score: 175.
  7. // CHALLENGE_7

    Stretch Challenge: Word frequency counter.

    Steps:

    1. Given list words = ["apple", "banana", "apple", "cherry", "banana", "apple"].
    2. Count frequency into a dictionary.
    3. Print Apple count: 3.
MODULE_06 // LOOPS — WHILE & FOROPEN →
  1. // CHALLENGE_1

    Warm-up 1: Count from 1 to 3 using a while loop.

    Steps:

    1. Start i = 1.
    2. Loop while i <= 3, print Count: i, increment i += 1.
  2. // CHALLENGE_2

    Warm-up 2: Print numbers 0 to 2 using for loop and range.

    Steps:

    1. Use for num in range(3):.
    2. Print Num: num.
  3. // CHALLENGE_3

    Warm-up 3: Iterate over list of items.

    Steps:

    1. Given items = ["pen", "paper"].
    2. Loop over items printing Item: pen.
  4. // CHALLENGE_4

    Apply-it 1: Calculate sum of numbers 1 to 5.

    Steps:

    1. Initialize total = 0.
    2. Use for n in range(1, 6): adding n to total.
    3. Print Sum: 15.
  5. // CHALLENGE_5

    Apply-it 2: Filter even numbers using continue.

    Steps:

    1. Loop for x in range(1, 6):.
    2. If x % 2 != 0 (odd), continue.
    3. Print Even: x.
  6. // CHALLENGE_6

    Apply-it 3: Stop search when target found using break.

    Steps:

    1. Given data = [10, 25, 50, 99, 100].
    2. Loop through data; if item == 50, print Found 50! and break.
  7. // CHALLENGE_7

    Stretch Challenge: Multiplication Table Generator.

    Steps:

    1. Print multiplication table for 3 up to 3 x 3.
    2. Output formatted:

    3 x 1 = 3 3 x 2 = 6 3 x 3 = 9

MODULE_07 // FUNCTIONS, SCOPE & RECURSIONOPEN →
  1. // CHALLENGE_1

    Warm-up 1: Define a greeting function.

    Steps:

    1. Define function welcome(name).
    2. Print Welcome, Alex!.
    3. Call welcome("Alex").
  2. // CHALLENGE_2

    Warm-up 2: Write a square function with return.

    Steps:

    1. Define function square(num) returning num * num.
    2. Call square(4) and print Square: 16.
  3. // CHALLENGE_3

    Warm-up 3: Recursive countdown function.

    Steps:

    1. Define rec_count(n).
    2. Base case: if n <= 0 print Done! and return.
    3. Otherwise print n and call rec_count(n - 1).
    4. Call rec_count(2).
  4. // CHALLENGE_4

    Apply-it 1: Calculate total order price with tax parameter.

    Steps:

    1. Define calc_total(price, tax=0.08) returning price * (1 + tax).
    2. Call calc_total(100) and print Total: $108.00.
  5. // CHALLENGE_5

    Apply-it 2: Find maximum of two numbers function.

    Steps:

    1. Define function max_num(a, b).
    2. Return a if a > b else return b.
    3. Call max_num(15, 42) and print Max: 42.
  6. // CHALLENGE_6

    Apply-it 3: Recursive sum of numbers from 1 to n.

    Steps:

    1. Define recursive function rec_sum(n).
    2. Base case: if n <= 1 return 1.
    3. Recursive case: return n + rec_sum(n - 1).
    4. Call rec_sum(4) and print Recursive Sum: 10.
  7. // CHALLENGE_7

    Stretch Challenge: Explain Recursion & Calculate Fibonacci.

    Steps:

    1. Print explanation: Recursion is a function calling itself until hitting a base case..
    2. Define recursive fib(n) (base case: if n <= 1 return n, recursive: fib(n-1) + fib(n-2)).
    3. Call fib(6) and print Fib(6): 8.
MODULE_08 // FILE I/O & FILE SYSTEMSOPEN →
  1. // CHALLENGE_1

    Let's practice writing to and reading from files safely!

    Steps to Complete:

    1. Open data.txt in write mode and write 3 lines: `Line 1

    Line 2 Line 3`.

    1. Open data.txt in read mode and count the number of lines.
    2. Print Total Lines: 3.

    Expected Output:

    TEXT
  2. // CHALLENGE_2

    Let's build an environment configuration file parser!

    Steps to Complete:

    1. Write `PORT=5432

    HOST=localhost to env.txt`.

    1. Read env.txt line by line, splitting by = into a dictionary.
    2. Print Config Host: localhost.

    Expected Output:

    TEXT
  3. // CHALLENGE_3

    Let's build an audit log filter that counts failed HTTP requests!

    Steps to Complete:

    1. Write 4 lines to access.log: `200 OK

    404 NOT_FOUND 200 OK 500 SERVER_ERROR`.

    1. Read access.log and count lines that do not start with 200.
    2. Print Failed Requests: 2.

    Expected Output:

    TEXT
MODULE_09 // OOP PART 1 — CLASSES, OBJECTS & __INIT__OPEN →
  1. // CHALLENGE_1

    Warm-up 1: Create a Person class with name and age.

    Steps:

    1. Define class Person with __init__(self, name, age).
    2. Instantiate p = Person("Ada", 30).
    3. Print Ada is 30 years old..
  2. // CHALLENGE_2

    Warm-up 2: Add a greeting method to a User class.

    Steps:

    1. Class User with __init__(self, username).
    2. Method greet(self) returning Hello, <username>!.
    3. Instantiate u = User("DevGuy") and print u.greet().
  3. // CHALLENGE_3

    Warm-up 3: Rectangle class with area calculation.

    Steps:

    1. Class Rectangle(width, height).
    2. Method area(self) returning width * height.
    3. Instantiate r = Rectangle(5, 4) and print Area: 20.
  4. // CHALLENGE_4

    Apply-it 1: Counter class with increment and reset.

    Steps:

    1. Class Counter starting self.value = 0.
    2. Method increment(self) adding 1.
    3. Method reset(self) setting value back to 0.
    4. Increment twice, print Count: 2.
  5. // CHALLENGE_5

    Apply-it 2: Circle class with perimeter calculation.

    Steps:

    1. Class Circle(radius).
    2. Method perimeter(self) returning 2 * 3.14 * self.radius.
    3. Instantiate c = Circle(10) and print Perimeter: 62.8.
  6. // CHALLENGE_6

    Apply-it 3: Track shared class attribute vs instance attribute.

    Steps:

    1. Class Employee with class attribute company = "TechCorp".
    2. Instance attribute name.
    3. Instantiate e1 = Employee("Sam") and e2 = Employee("Kim").
    4. Print Sam works at TechCorp, Kim works at TechCorp.
  7. // CHALLENGE_7

    Stretch Challenge: Explain Classes & Build Shopping Basket.

    Steps:

    1. Print explanation: A class is a blueprint; objects are instances created from it..
    2. Class Basket with self.items = [].
    3. Methods add_item(self, item) and get_items(self).
    4. Add "Apple" and "Banana", print Items: ['Apple', 'Banana'].
MODULE_10 // OOP PART 2 — INHERITANCE & POLYMORPHISMOPEN →
  1. // CHALLENGE_1

    Warm-up 1: Basic subclass creation.

    Steps:

    1. Class Animal with method sound(self) printing Generic sound.
    2. Subclass Dog(Animal).
    3. Instantiate d = Dog() and call d.sound().
  2. // CHALLENGE_2

    Warm-up 2: Override a method in a subclass.

    Steps:

    1. Class Shape with describe(self) returning Shape.
    2. Subclass Square(Shape) overriding describe(self) returning Square.
    3. Instantiate s = Square() and print s.describe().
  3. // CHALLENGE_3

    Warm-up 3: Use super() to initialize parent properties.

    Steps:

    1. Class Device(brand).
    2. Subclass Phone(Device, model) calling super().__init__(brand).
    3. Instantiate p = Phone("Apple", "iPhone") and print Apple iPhone.
  4. // CHALLENGE_4

    Apply-it 1: Polymorphism with payment processors.

    Steps:

    1. Classes CreditCard and PayPal, both with method pay(amount).
    2. CreditCard.pay(100) prints Card charged: $100.
    3. PayPal.pay(100) prints PayPal charged: $100.
    4. Loop through [CreditCard(), PayPal()] calling pay(100).
  5. // CHALLENGE_5

    Apply-it 2: Encapsulation with protected attribute and getter.

    Steps:

    1. Class BankAccount with protected _balance.
    2. Method get_balance(self) returning _balance.
    3. Instantiate with 250 and print Balance: $250.
  6. // CHALLENGE_6

    Apply-it 3: Multi-level inheritance (Vehicle -> FourWheeler -> SUV).

    Steps:

    1. Vehicle with type = "Vehicle".
    2. FourWheeler(Vehicle) setting wheels = 4.
    3. Instantiate suv = FourWheeler() and print Vehicle has 4 wheels.
  7. // CHALLENGE_7

    Stretch Challenge: Explain Inheritance & Polymorphism with Employee hierarchy.

    Steps:

    1. Print explanation: Inheritance reuses parent code; polymorphism allows uniform method calls..
    2. Worker with work(self) returning Working....
    3. Developer(Worker) overriding work(self) returning Writing Code....
    4. Loop [Worker(), Developer()] printing output.
MODULE_11 // ERROR & EXCEPTION HANDLINGOPEN →
  1. // CHALLENGE_1

    Let's handle division by zero errors safely with try / except!

    Steps to Complete:

    1. Define safe_divide(a, b).
    2. Use try / except to catch ZeroDivisionError, print Error: Division by zero, and return None.
    3. Call safe_divide(10, 0).

    Input: a = 10, b = 0

    Expected Output:

    TEXT
  2. // CHALLENGE_2

    Let's handle invalid user age inputs gracefully!

    Steps to Complete:

    1. Define parse_age(val) that tries to convert val to int.
    2. Catch ValueError if conversion fails, print Invalid age integer, and return -1.
    3. Call parse_age('thirty').

    Input: val = 'thirty'

    Expected Output:

    TEXT
  3. // CHALLENGE_3

    Let's create and catch a custom security exception!

    Steps to Complete:

    1. Define class InvalidTokenError(Exception).
    2. Write verify_token(token) raising InvalidTokenError('Token expired') if token != 'VALID_SECRET'.
    3. Call verify_token('EXPIRED_XYZ') inside try / except and print Caught: Token expired.

    Input: token = 'EXPIRED_XYZ'

    Expected Output:

    TEXT
MODULE_12 // LIST, SET & DICTIONARY COMPREHENSIONSOPEN →
  1. // CHALLENGE_1

    Let's use a list comprehension to calculate squares of even numbers!

    Steps to Complete:

    1. Given numbers = range(1, 11).
    2. Use list comprehension [x*x for x in numbers if x % 2 == 0] to produce [4, 16, 36, 64, 100].
    3. Print Even Squares: [4, 16, 36, 64, 100].

    Expected Output:

    TEXT
  2. // CHALLENGE_2

    Let's use a dictionary comprehension to filter and double values!

    Steps to Complete:

    1. Given payload = {'a': 5, 'b': 12, 'c': 3, 'd': 20}.
    2. Use dict comprehension to keep keys where value > 5 and double their values.
    3. Print Filtered Doubled: {'b': 24, 'd': 40}.

    Expected Output:

    TEXT
  3. // CHALLENGE_3

    Let's use a set comprehension to normalize and alphabetize names!

    Steps to Complete:

    1. Given names = ['alice', 'bob', 'alice', 'charlie', 'bob'].
    2. Use set comprehension to uppercase names, then sort into an alphabetical list.
    3. Print Unique Names: ['ALICE', 'BOB', 'CHARLIE'].

    Expected Output:

    TEXT
MODULE_13 // MINI-PROJECT: BUILDING A MODULAR APPLICATIONOPEN →
  1. // CHALLENGE_1

    Let's refactor calculations into a modular function pipeline!

    Steps to Complete:

    1. Write validate_input(val) returning True if val > 0.
    2. Write calculate_tax(val) returning val * 0.10.
    3. Write process_order(val) calling validate_input and returning calculate_tax.
    4. Call process_order(100) and print Tax: 10.0.

    Expected Output:

    TEXT
  2. // CHALLENGE_2

    Let's build an Inventory management class!

    Steps to Complete:

    1. Create class Inventory with self.items = {}.
    2. Add add_stock(name, qty) and get_stock(name).
    3. Add 'Laptops' (+50) and print Laptops in Stock: 50.

    Expected Output:

    TEXT
  3. // CHALLENGE_3

    Let's write a main entry point guard script!

    Steps to Complete:

    1. Write bootstrap(). function printing Application Bootstrapped Successfully.
    2. Call bootstrap() inside an if __name__ == '__main__': block.

    Expected Output:

    TEXT
MODULE_14 // WORKING WITH STANDARD & THIRD-PARTY LIBRARIESOPEN →
  1. // CHALLENGE_1

    Let's generate random numbers with a fixed seed for reproducible results!

    Steps to Complete:

    1. Import random module and set random.seed(42).
    2. Generate 3 random integers between 1 and 100 inclusive.
    3. Print Random Numbers: [82, 14, 3].

    Expected Output:

    TEXT
  2. // CHALLENGE_2

    Let's parse and add days to dates using the datetime module!

    Steps to Complete:

    1. Parse date string '2026-07-29' using datetime.strptime.
    2. Add 10 days using timedelta(days=10).
    3. Format resulting date as 'YYYY-MM-DD' and print Target Date: 2026-08-08.

    Expected Output:

    TEXT
  3. // CHALLENGE_3

    Let me help you extract email addresses from text using regular expressions!

    Steps to Complete:

    1. Given text = 'Contact support@domain.com or admin@server.org for help'.
    2. Use re.findall() with regex pattern r'[w.-]+@[w.-]+.[a-zA-Z]+'.
    3. Print Emails Found: ['support@domain.com', 'admin@server.org'].

    Expected Output:

    TEXT
MODULE_15 // WORKING WITH JSON, CSV & STRUCTURING DATAOPEN →
  1. // CHALLENGE_1

    Let's merge two JSON data strings into one object!

    Steps to Complete:

    1. Given json1 = '{"a": 10, "b": 20}' and json2 = '{"b": 30, "c": 40}'.
    2. Parse both into dicts using json.loads(), merge dicts (json2 updates json1).
    3. Serialize merged dict back to JSON text with json.dumps() and print Merged JSON: {"a": 10, "b": 30, "c": 40}.

    Expected Output:

    TEXT
  2. // CHALLENGE_2

    Let's parse a CSV string and calculate total scores!

    Steps to Complete:

    1. Given `csv_data = 'name,score

    Alice,90 Bob,80'`.

    1. Use csv.DictReader to parse lines and sum scores as integers.
    2. Print Total Score: 170.

    Expected Output:

    TEXT
  3. // CHALLENGE_3

    Let's convert raw CSV records into a typed JSON array!

    Steps to Complete:

    1. Given `csv_text = 'id,active

    1,true 2,false'`.

    1. Parse rows with csv.DictReader, converting id to int and active to boolean.
    2. Dump to JSON string and print JSON Output: [{"id": 1, "active": true}, {"id": 2, "active": false}].

    Expected Output:

    TEXT