Build a Computer with CPU and RAM Components

Medium Composition & Aggregation PRO
🔒 Login to Unlock

Problem Statement

Use strict composition. Build `CPU` (takes speed) and `RAM` (takes size) classes. Build a `Computer` class that takes both inputs and instantiates `CPU` and `RAM` internally. Add a `specs()` method that prints ‘CPU: [speed]GHz\nRAM: [size]GB’.

Input Format

A float (CPU speed) and an integer (RAM size) separated by space.

Output Format

Print the specs using strict formatting.

Constraints

None

Sample Input

3.5 16

Sample Output

CPU: 3.5GHz
RAM: 16GB

Explanation

A complete composition example. The computer manages the lifecycles of its internal hardware components.

Starter Code

class CPU:
    pass

class RAM:
    pass

class Computer:
    pass

if __name__ == '__main__':
    cpu_str, ram_str = input().split()
    # Construct computer and show specs
    pass

Limits

  • Time Limit: 1s
  • Memory Limit: 256MB

Embedded C Programming

Updated: March 15, 2026
Intermediate

Embedded systems rely on efficient low-level programming to interact directly with hardware. In this course, you will learn how to write practical Embedded C programs used in real microcontroller-based systems. Rather than focusing only on theory, this course follows a practice-driven approach. Each lesson includes hands-on coding exercises that simulate real firmware development tasks used