English
Tasks
Complete the task of the chosen difficulty level for your variant number.
All levels require a UML class diagram with inheritance or implementation directions, signatures, and annotations. For Protocol, explain why a class satisfies it without explicit inheritance; for ABC, demonstrate rejection of instantiating an incomplete class. At the advanced level, provide named CLI parameters and repeatable --item records with documented fields, --help, and a keyboard menu when no arguments are given. Errors go to stderr with code 2, success with code 0. Print a polymorphic table and totals. All rates, prices, and norms in the task specifications are for learning purposes. No messages, payments, or requests are sent externally.
Variants
Variant 1. Zoo
1. Initial level. Create a Python 3.14 console program: enter the species cat or horse and a mass of 1..1000 kg. Shared contract: ABC Animal, method food(); implementations: Cat needs 0.03*mass kg of feed, Horse needs 0.02*mass. Invoke operations through the shared interface and print the result. Annotate the methods and provide UML with inheritance or implementation directions.
2. Basic level. Create a Python 3.14 console program: enter the species cat or horse and a mass of 1..1000 kg. Shared contract: ABC Animal, method food(); implementations: Cat needs 0.03*mass kg of feed, Horse needs 0.02*mass. Invoke operations through the shared interface and print the result. Accept up to 20 objects, validate ranges, and produce a polymorphic table without conditions on concrete types; apply the same contract checks to all implementations. Annotate the methods and provide UML with inheritance or implementation directions.
3. Advanced level. Create a Python 3.14 console program: enter the species cat or horse and a mass of 1..1000 kg. Shared contract: ABC Animal, method food(); implementations: Cat needs 0.03*mass kg of feed, Horse needs 0.02*mass. Invoke operations through the shared interface and print the result. Accept up to 20 objects, validate ranges, and produce a polymorphic table without conditions on concrete types; apply the same contract checks to all implementations. Extension: group animals by species and total their rations; a mixin formats the name. Add --help, named arguments, and repeatable --item with documented fields; without arguments, use keyboard input. Errors go to stderr with code 2, success with code 0. Provide totals and at least five checks, including a rejection. Annotate the methods and provide UML with inheritance or implementation directions.
Variant 2. Notifications
1. Initial level. Create a Python 3.14 console program: enter the type email, sms, or push and nonempty text up to 100 characters. Shared contract: Protocol Notifier, method format(text); implementations: Email adds the prefix EMAIL:, Sms adds SMS:, Push adds PUSH:; construct the string locally only. Invoke operations through the shared interface and print the result. Annotate the methods and provide UML with inheritance or implementation directions.
2. Basic level. Create a Python 3.14 console program: enter the type email, sms, or push and nonempty text up to 100 characters. Shared contract: Protocol Notifier, method format(text); implementations: Email adds the prefix EMAIL:, Sms adds SMS:, Push adds PUSH:; construct the string locally only. Invoke operations through the shared interface and print the result. Accept up to 20 objects, validate ranges, and produce a polymorphic table without conditions on concrete types; apply the same contract checks to all implementations. Annotate the methods and provide UML with inheritance or implementation directions.
3. Advanced level. Create a Python 3.14 console program: enter the type email, sms, or push and nonempty text up to 100 characters. Shared contract: Protocol Notifier, method format(text); implementations: Email adds the prefix EMAIL:, Sms adds SMS:, Push adds PUSH:; construct the string locally only. Invoke operations through the shared interface and print the result. Accept up to 20 objects, validate ranges, and produce a polymorphic table without conditions on concrete types; apply the same contract checks to all implementations. Extension: process a batch of up to 20 synthetic recipients; no external sending. Add --help, named arguments, and repeatable --item with documented fields; without arguments, use keyboard input. Errors go to stderr with code 2, success with code 0. Provide totals and at least five checks, including a rejection. Annotate the methods and provide UML with inheritance or implementation directions.
Variant 3. Income taxes
1. Initial level. Create a Python 3.14 console program: enter the type salary or gift and an amount of 0..100000 UAH. Shared contract: ABC Income, method tax(); implementations: the sample tax is 18 percent for Salary and 5 percent for Gift. Invoke operations through the shared interface and print the result. Annotate the methods and provide UML with inheritance or implementation directions.
2. Basic level. Create a Python 3.14 console program: enter the type salary or gift and an amount of 0..100000 UAH. Shared contract: ABC Income, method tax(); implementations: the sample tax is 18 percent for Salary and 5 percent for Gift. Invoke operations through the shared interface and print the result. Accept up to 20 objects, validate ranges, and produce a polymorphic table without conditions on concrete types; apply the same contract checks to all implementations. Annotate the methods and provide UML with inheritance or implementation directions.
3. Advanced level. Create a Python 3.14 console program: enter the type salary or gift and an amount of 0..100000 UAH. Shared contract: ABC Income, method tax(); implementations: the sample tax is 18 percent for Salary and 5 percent for Gift. Invoke operations through the shared interface and print the result. Accept up to 20 objects, validate ranges, and produce a polymorphic table without conditions on concrete types; apply the same contract checks to all implementations. Extension: a declaration with up to 20 incomes, totals by type, and a grand total; the rates are for learning purposes only. Add --help, named arguments, and repeatable --item with documented fields; without arguments, use keyboard input. Errors go to stderr with code 2, success with code 0. Provide totals and at least five checks, including a rejection. Annotate the methods and provide UML with inheritance or implementation directions.
Variant 4. Freight transportation
1. Initial level. Create a Python 3.14 console program: enter a mass of 0.1..100 t, a distance of 1..1000 km, and the type road, water, or air. Shared contract: ABC Transport, method cost(mass, distance); implementations: sample rates per ton-kilometer are 2, 1, and 5 respectively. Invoke operations through the shared interface and print the result. Annotate the methods and provide UML with inheritance or implementation directions.
2. Basic level. Create a Python 3.14 console program: enter a mass of 0.1..100 t, a distance of 1..1000 km, and the type road, water, or air. Shared contract: ABC Transport, method cost(mass, distance); implementations: sample rates per ton-kilometer are 2, 1, and 5 respectively. Invoke operations through the shared interface and print the result. Accept up to 20 objects, validate ranges, and produce a polymorphic table without conditions on concrete types; apply the same contract checks to all implementations. Annotate the methods and provide UML with inheritance or implementation directions.
3. Advanced level. Create a Python 3.14 console program: enter a mass of 0.1..100 t, a distance of 1..1000 km, and the type road, water, or air. Shared contract: ABC Transport, method cost(mass, distance); implementations: sample rates per ton-kilometer are 2, 1, and 5 respectively. Invoke operations through the shared interface and print the result. Accept up to 20 objects, validate ranges, and produce a polymorphic table without conditions on concrete types; apply the same contract checks to all implementations. Extension: compare all methods for each load and choose the cheapest; implement capacity rules as a component. Add --help, named arguments, and repeatable --item with documented fields; without arguments, use keyboard input. Errors go to stderr with code 2, success with code 0. Provide totals and at least five checks, including a rejection. Annotate the methods and provide UML with inheritance or implementation directions.
Variant 5. Geometric solids
1. Initial level. Create a Python 3.14 console program: enter the type cube or sphere and a size of 0.1..100. Shared contract: ABC Solid, methods volume() and surface(); implementations: Cube calculates a**3 and 6*a*a, Sphere calculates 4*pi*r**3/3 and 4*pi*r*r. Invoke operations through the shared interface and print the result. Annotate the methods and provide UML with inheritance or implementation directions.
2. Basic level. Create a Python 3.14 console program: enter the type cube or sphere and a size of 0.1..100. Shared contract: ABC Solid, methods volume() and surface(); implementations: Cube calculates a**3 and 6*a*a, Sphere calculates 4*pi*r**3/3 and 4*pi*r*r. Invoke operations through the shared interface and print the result. Accept up to 20 objects, validate ranges, and produce a polymorphic table without conditions on concrete types; apply the same contract checks to all implementations. Annotate the methods and provide UML with inheritance or implementation directions.
3. Advanced level. Create a Python 3.14 console program: enter the type cube or sphere and a size of 0.1..100. Shared contract: ABC Solid, methods volume() and surface(); implementations: Cube calculates a**3 and 6*a*a, Sphere calculates 4*pi*r**3/3 and 4*pi*r*r. Invoke operations through the shared interface and print the result. Accept up to 20 objects, validate ranges, and produce a polymorphic table without conditions on concrete types; apply the same contract checks to all implementations. Extension: a polymorphic catalog of up to 20 solids, sorted by volume, with a sum of surface areas. Add --help, named arguments, and repeatable --item with documented fields; without arguments, use keyboard input. Errors go to stderr with code 2, success with code 0. Provide totals and at least five checks, including a rejection. Annotate the methods and provide UML with inheritance or implementation directions.
Variant 6. Employees
1. Initial level. Create a Python 3.14 console program: enter the type hourly or salaried, hours of 0..200 and a rate of 0..1000 or a salary of 0..100000. Shared contract: ABC Worker, method pay(); implementations: Hourly returns hours*rate, Salaried returns the salary. Invoke operations through the shared interface and print the result. Annotate the methods and provide UML with inheritance or implementation directions.
2. Basic level. Create a Python 3.14 console program: enter the type hourly or salaried, hours of 0..200 and a rate of 0..1000 or a salary of 0..100000. Shared contract: ABC Worker, method pay(); implementations: Hourly returns hours*rate, Salaried returns the salary. Invoke operations through the shared interface and print the result. Accept up to 20 objects, validate ranges, and produce a polymorphic table without conditions on concrete types; apply the same contract checks to all implementations. Annotate the methods and provide UML with inheritance or implementation directions.
3. Advanced level. Create a Python 3.14 console program: enter the type hourly or salaried, hours of 0..200 and a rate of 0..1000 or a salary of 0..100000. Shared contract: ABC Worker, method pay(); implementations: Hourly returns hours*rate, Salaried returns the salary. Invoke operations through the shared interface and print the result. Accept up to 20 objects, validate ranges, and produce a polymorphic table without conditions on concrete types; apply the same contract checks to all implementations. Extension: add Commission with sample pay of 5 percent of sales and calculate the total payroll. Add --help, named arguments, and repeatable --item with documented fields; without arguments, use keyboard input. Errors go to stderr with code 2, success with code 0. Provide totals and at least five checks, including a rejection. Annotate the methods and provide UML with inheritance or implementation directions.
Variant 7. Payment methods
1. Initial level. Create a Python 3.14 console program: enter the type cash or wallet and an integer amount of 1..100000 kopiykas. Shared contract: Protocol Payable, method pay(cents); implementations: Cash and Wallet only return different confirmations of a local simulation. Invoke operations through the shared interface and print the result. Annotate the methods and provide UML with inheritance or implementation directions.
2. Basic level. Create a Python 3.14 console program: enter the type cash or wallet and an integer amount of 1..100000 kopiykas. Shared contract: Protocol Payable, method pay(cents); implementations: Cash and Wallet only return different confirmations of a local simulation. Invoke operations through the shared interface and print the result. Accept up to 20 objects, validate ranges, and produce a polymorphic table without conditions on concrete types; apply the same contract checks to all implementations. Annotate the methods and provide UML with inheritance or implementation directions.
3. Advanced level. Create a Python 3.14 console program: enter the type cash or wallet and an integer amount of 1..100000 kopiykas. Shared contract: Protocol Payable, method pay(cents); implementations: Cash and Wallet only return different confirmations of a local simulation. Invoke operations through the shared interface and print the result. Accept up to 20 objects, validate ranges, and produce a polymorphic table without conditions on concrete types; apply the same contract checks to all implementations. Extension: add Card with a sample fee of 1 percent and a shared report; no real payments. Add --help, named arguments, and repeatable --item with documented fields; without arguments, use keyboard input. Errors go to stderr with code 2, success with code 0. Provide totals and at least five checks, including a rejection. Annotate the methods and provide UML with inheritance or implementation directions.
Variant 8. Document workflow
1. Initial level. Create a Python 3.14 console program: enter the type order or letter, a number, a title, and a recipient. Shared contract: ABC Document, method validate(); implementations: Order requires a positive number and a title, Letter additionally requires a nonempty recipient. Invoke operations through the shared interface and print the result. Annotate the methods and provide UML with inheritance or implementation directions.
2. Basic level. Create a Python 3.14 console program: enter the type order or letter, a number, a title, and a recipient. Shared contract: ABC Document, method validate(); implementations: Order requires a positive number and a title, Letter additionally requires a nonempty recipient. Invoke operations through the shared interface and print the result. Accept up to 20 objects, validate ranges, and produce a polymorphic table without conditions on concrete types; apply the same contract checks to all implementations. Annotate the methods and provide UML with inheritance or implementation directions.
3. Advanced level. Create a Python 3.14 console program: enter the type order or letter, a number, a title, and a recipient. Shared contract: ABC Document, method validate(); implementations: Order requires a positive number and a title, Letter additionally requires a nonempty recipient. Invoke operations through the shared interface and print the result. Accept up to 20 objects, validate ranges, and produce a polymorphic table without conditions on concrete types; apply the same contract checks to all implementations. Extension: the render template method calls validate before constructing a string; keep a failure log in a separate component. Add --help, named arguments, and repeatable --item with documented fields; without arguments, use keyboard input. Errors go to stderr with code 2, success with code 0. Provide totals and at least five checks, including a rejection. Annotate the methods and provide UML with inheritance or implementation directions.
Variant 9. Game characters
1. Initial level. Create a Python 3.14 console program: enter the type warrior, mage, or archer and a power of 1..100. Shared contract: ABC Character, method attack(); implementations: sample damage is 2*power for Warrior, 3*power for Mage, and power+10 for Archer. Invoke operations through the shared interface and print the result. Annotate the methods and provide UML with inheritance or implementation directions.
2. Basic level. Create a Python 3.14 console program: enter the type warrior, mage, or archer and a power of 1..100. Shared contract: ABC Character, method attack(); implementations: sample damage is 2*power for Warrior, 3*power for Mage, and power+10 for Archer. Invoke operations through the shared interface and print the result. Accept up to 20 objects, validate ranges, and produce a polymorphic table without conditions on concrete types; apply the same contract checks to all implementations. Annotate the methods and provide UML with inheritance or implementation directions.
3. Advanced level. Create a Python 3.14 console program: enter the type warrior, mage, or archer and a power of 1..100. Shared contract: ABC Character, method attack(); implementations: sample damage is 2*power for Warrior, 3*power for Mage, and power+10 for Archer. Invoke operations through the shared interface and print the result. Accept up to 20 objects, validate ranges, and produce a polymorphic table without conditions on concrete types; apply the same contract checks to all implementations. Extension: polymorphically simulate up to 10 turns with nonnegative health and a common contract for turn costs. Add --help, named arguments, and repeatable --item with documented fields; without arguments, use keyboard input. Errors go to stderr with code 2, success with code 0. Provide totals and at least five checks, including a rejection. Annotate the methods and provide UML with inheritance or implementation directions.
Variant 10. Electrical appliances
1. Initial level. Create a Python 3.14 console program: enter the type lamp or heater, a power of 1..3000 W, and a time of 0..24 hours. Shared contract: ABC Device, method energy(hours); implementations: both calculate power*hours/1000 kWh; Heater also has a duty factor of 0..1. Invoke operations through the shared interface and print the result. Annotate the methods and provide UML with inheritance or implementation directions.
2. Basic level. Create a Python 3.14 console program: enter the type lamp or heater, a power of 1..3000 W, and a time of 0..24 hours. Shared contract: ABC Device, method energy(hours); implementations: both calculate power*hours/1000 kWh; Heater also has a duty factor of 0..1. Invoke operations through the shared interface and print the result. Accept up to 20 objects, validate ranges, and produce a polymorphic table without conditions on concrete types; apply the same contract checks to all implementations. Annotate the methods and provide UML with inheritance or implementation directions.
3. Advanced level. Create a Python 3.14 console program: enter the type lamp or heater, a power of 1..3000 W, and a time of 0..24 hours. Shared contract: ABC Device, method energy(hours); implementations: both calculate power*hours/1000 kWh; Heater also has a duty factor of 0..1. Invoke operations through the shared interface and print the result. Accept up to 20 objects, validate ranges, and produce a polymorphic table without conditions on concrete types; apply the same contract checks to all implementations. Extension: a mixin logs local switch-ons; summarize household energy use by device. Add --help, named arguments, and repeatable --item with documented fields; without arguments, use keyboard input. Errors go to stderr with code 2, success with code 0. Provide totals and at least five checks, including a rejection. Annotate the methods and provide UML with inheritance or implementation directions.
Variant 11. Bank accounts
1. Initial level. Create a Python 3.14 console program: enter the type current or deposit and a balance of 0..100000 UAH. Shared contract: ABC Account, method month_change(); implementations: Current gives a change of 0, Deposit gives a sample 0.5 percent of the balance. Invoke operations through the shared interface and print the result. Annotate the methods and provide UML with inheritance or implementation directions.
2. Basic level. Create a Python 3.14 console program: enter the type current or deposit and a balance of 0..100000 UAH. Shared contract: ABC Account, method month_change(); implementations: Current gives a change of 0, Deposit gives a sample 0.5 percent of the balance. Invoke operations through the shared interface and print the result. Accept up to 20 objects, validate ranges, and produce a polymorphic table without conditions on concrete types; apply the same contract checks to all implementations. Annotate the methods and provide UML with inheritance or implementation directions.
3. Advanced level. Create a Python 3.14 console program: enter the type current or deposit and a balance of 0..100000 UAH. Shared contract: ABC Account, method month_change(); implementations: Current gives a change of 0, Deposit gives a sample 0.5 percent of the balance. Invoke operations through the shared interface and print the result. Accept up to 20 objects, validate ranges, and produce a polymorphic table without conditions on concrete types; apply the same contract checks to all implementations. Extension: add Credit with nonnegative debt and 1 percent interest; the report separates income and expenses without real transactions. Add --help, named arguments, and repeatable --item with documented fields; without arguments, use keyboard input. Errors go to stderr with code 2, success with code 0. Provide totals and at least five checks, including a rejection. Annotate the methods and provide UML with inheritance or implementation directions.
Variant 12. Insurance
1. Initial level. Create a Python 3.14 console program: enter the type car or home and an insured amount of 1..1000000 UAH. Shared contract: ABC Policy, method premium(); implementations: the sample premium is 3 percent of the amount for Car and 1 percent for Home. Invoke operations through the shared interface and print the result. Annotate the methods and provide UML with inheritance or implementation directions.
2. Basic level. Create a Python 3.14 console program: enter the type car or home and an insured amount of 1..1000000 UAH. Shared contract: ABC Policy, method premium(); implementations: the sample premium is 3 percent of the amount for Car and 1 percent for Home. Invoke operations through the shared interface and print the result. Accept up to 20 objects, validate ranges, and produce a polymorphic table without conditions on concrete types; apply the same contract checks to all implementations. Annotate the methods and provide UML with inheritance or implementation directions.
3. Advanced level. Create a Python 3.14 console program: enter the type car or home and an insured amount of 1..1000000 UAH. Shared contract: ABC Policy, method premium(); implementations: the sample premium is 3 percent of the amount for Car and 1 percent for Home. Invoke operations through the shared interface and print the result. Accept up to 20 objects, validate ranges, and produce a polymorphic table without conditions on concrete types; apply the same contract checks to all implementations. Extension: add a third sample policy at 2 percent, a shared catalog, and sorting by premium. Add --help, named arguments, and repeatable --item with documented fields; without arguments, use keyboard input. Errors go to stderr with code 2, success with code 0. Provide totals and at least five checks, including a rejection. Annotate the methods and provide UML with inheritance or implementation directions.
Variant 13. Orchestra
1. Initial level. Create a Python 3.14 console program: enter the type strings, wind, or drums and a note name. Shared contract: Protocol Playable, method play(note); implementations: three independent classes return strings with the instrument type and note. Invoke operations through the shared interface and print the result. Annotate the methods and provide UML with inheritance or implementation directions.
2. Basic level. Create a Python 3.14 console program: enter the type strings, wind, or drums and a note name. Shared contract: Protocol Playable, method play(note); implementations: three independent classes return strings with the instrument type and note. Invoke operations through the shared interface and print the result. Accept up to 20 objects, validate ranges, and produce a polymorphic table without conditions on concrete types; apply the same contract checks to all implementations. Annotate the methods and provide UML with inheritance or implementation directions.
3. Advanced level. Create a Python 3.14 console program: enter the type strings, wind, or drums and a note name. Shared contract: Protocol Playable, method play(note); implementations: three independent classes return strings with the instrument type and note. Invoke operations through the shared interface and print the result. Accept up to 20 objects, validate ranges, and produce a polymorphic table without conditions on concrete types; apply the same contract checks to all implementations. Extension: an orchestra aggregates up to 20 instruments, with a score of up to 10 notes; output text, not audio. Add --help, named arguments, and repeatable --item with documented fields; without arguments, use keyboard input. Errors go to stderr with code 2, success with code 0. Provide totals and at least five checks, including a rejection. Annotate the methods and provide UML with inheritance or implementation directions.
Variant 14. Academic subjects
1. Initial level. Create a Python 3.14 console program: enter the type lecture, practice, or online and hours of 0..100. Shared contract: ABC Course, method workload(); implementations: sample workload is 1.2*h for Lecture, h for Practice, and 0.8*h for Online. Invoke operations through the shared interface and print the result. Annotate the methods and provide UML with inheritance or implementation directions.
2. Basic level. Create a Python 3.14 console program: enter the type lecture, practice, or online and hours of 0..100. Shared contract: ABC Course, method workload(); implementations: sample workload is 1.2*h for Lecture, h for Practice, and 0.8*h for Online. Invoke operations through the shared interface and print the result. Accept up to 20 objects, validate ranges, and produce a polymorphic table without conditions on concrete types; apply the same contract checks to all implementations. Annotate the methods and provide UML with inheritance or implementation directions.
3. Advanced level. Create a Python 3.14 console program: enter the type lecture, practice, or online and hours of 0..100. Shared contract: ABC Course, method workload(); implementations: sample workload is 1.2*h for Lecture, h for Practice, and 0.8*h for Online. Invoke operations through the shared interface and print the result. Accept up to 20 objects, validate ranges, and produce a polymorphic table without conditions on concrete types; apply the same contract checks to all implementations. Extension: a curriculum with up to 20 courses, total workload, and coefficients replaced through a strategy. Add --help, named arguments, and repeatable --item with documented fields; without arguments, use keyboard input. Errors go to stderr with code 2, success with code 0. Provide totals and at least five checks, including a rejection. Annotate the methods and provide UML with inheritance or implementation directions.
Variant 15. Delivery methods
1. Initial level. Create a Python 3.14 console program: enter the type courier, post, or pickup and a distance of 0..1000 km. Shared contract: Protocol Delivery, method hours(distance); implementations: Courier gives 2+d/50, Post gives 24+d/100, Pickup gives 0 hours. Invoke operations through the shared interface and print the result. Annotate the methods and provide UML with inheritance or implementation directions.
2. Basic level. Create a Python 3.14 console program: enter the type courier, post, or pickup and a distance of 0..1000 km. Shared contract: Protocol Delivery, method hours(distance); implementations: Courier gives 2+d/50, Post gives 24+d/100, Pickup gives 0 hours. Invoke operations through the shared interface and print the result. Accept up to 20 objects, validate ranges, and produce a polymorphic table without conditions on concrete types; apply the same contract checks to all implementations. Annotate the methods and provide UML with inheritance or implementation directions.
3. Advanced level. Create a Python 3.14 console program: enter the type courier, post, or pickup and a distance of 0..1000 km. Shared contract: Protocol Delivery, method hours(distance); implementations: Courier gives 2+d/50, Post gives 24+d/100, Pickup gives 0 hours. Invoke operations through the shared interface and print the result. Accept up to 20 objects, validate ranges, and produce a polymorphic table without conditions on concrete types; apply the same contract checks to all implementations. Extension: compare methods for up to 20 orders and find the fastest; explicitly document restrictions on delivery types. Add --help, named arguments, and repeatable --item with documented fields; without arguments, use keyboard input. Errors go to stderr with code 2, success with code 0. Provide totals and at least five checks, including a rejection. Annotate the methods and provide UML with inheritance or implementation directions.
Variant 16. Chess pieces
1. Initial level. Create a Python 3.14 console program: enter the type rook, bishop, or knight and coordinates of 1..8. Shared contract: ABC Piece, method moves(); implementations: on an empty board, return all legal moves for the piece without going out of bounds. Invoke operations through the shared interface and print the result. Annotate the methods and provide UML with inheritance or implementation directions.
2. Basic level. Create a Python 3.14 console program: enter the type rook, bishop, or knight and coordinates of 1..8. Shared contract: ABC Piece, method moves(); implementations: on an empty board, return all legal moves for the piece without going out of bounds. Invoke operations through the shared interface and print the result. Accept up to 20 objects, validate ranges, and produce a polymorphic table without conditions on concrete types; apply the same contract checks to all implementations. Annotate the methods and provide UML with inheritance or implementation directions.
3. Advanced level. Create a Python 3.14 console program: enter the type rook, bishop, or knight and coordinates of 1..8. Shared contract: ABC Piece, method moves(); implementations: on an empty board, return all legal moves for the piece without going out of bounds. Invoke operations through the shared interface and print the result. Accept up to 20 objects, validate ranges, and produce a polymorphic table without conditions on concrete types; apply the same contract checks to all implementations. Extension: Board aggregates pieces and passes occupied squares to a validation component; exclude the piece's own square and friendly pieces. Add --help, named arguments, and repeatable --item with documented fields; without arguments, use keyboard input. Errors go to stderr with code 2, success with code 0. Provide totals and at least five checks, including a rejection. Annotate the methods and provide UML with inheritance or implementation directions.
Variant 17. Smart home
1. Initial level. Create a Python 3.14 console program: enter the type temperature, motion, or smoke and a value. Shared contract: ABC Sensor, method status(); implementations: Temperature accepts -40..60 and flags values above 30, Motion and Smoke accept 0 or 1. Invoke operations through the shared interface and print the result. Annotate the methods and provide UML with inheritance or implementation directions.
2. Basic level. Create a Python 3.14 console program: enter the type temperature, motion, or smoke and a value. Shared contract: ABC Sensor, method status(); implementations: Temperature accepts -40..60 and flags values above 30, Motion and Smoke accept 0 or 1. Invoke operations through the shared interface and print the result. Accept up to 20 objects, validate ranges, and produce a polymorphic table without conditions on concrete types; apply the same contract checks to all implementations. Annotate the methods and provide UML with inheritance or implementation directions.
3. Advanced level. Create a Python 3.14 console program: enter the type temperature, motion, or smoke and a value. Shared contract: ABC Sensor, method status(); implementations: Temperature accepts -40..60 and flags values above 30, Motion and Smoke accept 0 or 1. Invoke operations through the shared interface and print the result. Accept up to 20 objects, validate ranges, and produce a polymorphic table without conditions on concrete types; apply the same contract checks to all implementations. Extension: polymorphically poll up to 20 sensors and report alarms; all readings are entered locally. Add --help, named arguments, and repeatable --item with documented fields; without arguments, use keyboard input. Errors go to stderr with code 2, success with code 0. Provide totals and at least five checks, including a rejection. Annotate the methods and provide UML with inheritance or implementation directions.
Variant 18. Cafe menu
1. Initial level. Create a Python 3.14 console program: enter the type drink or dish and a base price of 1..1000 UAH. Shared contract: ABC MenuItem, method price(); implementations: Drink returns the base price, Dish adds a sample fee of 10 UAH. Invoke operations through the shared interface and print the result. Annotate the methods and provide UML with inheritance or implementation directions.
2. Basic level. Create a Python 3.14 console program: enter the type drink or dish and a base price of 1..1000 UAH. Shared contract: ABC MenuItem, method price(); implementations: Drink returns the base price, Dish adds a sample fee of 10 UAH. Invoke operations through the shared interface and print the result. Accept up to 20 objects, validate ranges, and produce a polymorphic table without conditions on concrete types; apply the same contract checks to all implementations. Annotate the methods and provide UML with inheritance or implementation directions.
3. Advanced level. Create a Python 3.14 console program: enter the type drink or dish and a base price of 1..1000 UAH. Shared contract: ABC MenuItem, method price(); implementations: Drink returns the base price, Dish adds a sample fee of 10 UAH. Invoke operations through the shared interface and print the result. Accept up to 20 objects, validate ranges, and produce a polymorphic table without conditions on concrete types; apply the same contract checks to all implementations. Extension: Combo aggregates items and applies a 10 percent discount; the receipt processes all items polymorphically. Add --help, named arguments, and repeatable --item with documented fields; without arguments, use keyboard input. Errors go to stderr with code 2, success with code 0. Provide totals and at least five checks, including a rejection. Annotate the methods and provide UML with inheritance or implementation directions.
Variant 19. Report export
1. Initial level. Create a Python 3.14 console program: enter the type txt, csv, or html and up to 10 name:integer value pairs. Shared contract: Protocol Exporter, method export(rows); implementations: Txt constructs name=value lines, Csv and Html use the standard escaping for their respective formats. Invoke operations through the shared interface and print the result. Annotate the methods and provide UML with inheritance or implementation directions.
2. Basic level. Create a Python 3.14 console program: enter the type txt, csv, or html and up to 10 name:integer value pairs. Shared contract: Protocol Exporter, method export(rows); implementations: Txt constructs name=value lines, Csv and Html use the standard escaping for their respective formats. Invoke operations through the shared interface and print the result. Accept up to 20 objects, validate ranges, and produce a polymorphic table without conditions on concrete types; apply the same contract checks to all implementations. Annotate the methods and provide UML with inheritance or implementation directions.
3. Advanced level. Create a Python 3.14 console program: enter the type txt, csv, or html and up to 10 name:integer value pairs. Shared contract: Protocol Exporter, method export(rows); implementations: Txt constructs name=value lines, Csv and Html use the standard escaping for their respective formats. Invoke operations through the shared interface and print the result. Accept up to 20 objects, validate ranges, and produce a polymorphic table without conditions on concrete types; apply the same contract checks to all implementations. Extension: generate all three local strings from one dataset and test commas, quotes, and angle brackets; no publishing. Add --help, named arguments, and repeatable --item with documented fields; without arguments, use keyboard input. Errors go to stderr with code 2, success with code 0. Provide totals and at least five checks, including a rejection. Annotate the methods and provide UML with inheritance or implementation directions.
Variant 20. Track and field
1. Initial level. Create a Python 3.14 console program: enter the type run, jump, or throw and a positive result. Shared contract: ABC Event, method score(value); implementations: sample scores are 1000/seconds for Run, 100*metres for Jump, and 10*metres for Throw. Invoke operations through the shared interface and print the result. Annotate the methods and provide UML with inheritance or implementation directions.
2. Basic level. Create a Python 3.14 console program: enter the type run, jump, or throw and a positive result. Shared contract: ABC Event, method score(value); implementations: sample scores are 1000/seconds for Run, 100*metres for Jump, and 10*metres for Throw. Invoke operations through the shared interface and print the result. Accept up to 20 objects, validate ranges, and produce a polymorphic table without conditions on concrete types; apply the same contract checks to all implementations. Annotate the methods and provide UML with inheritance or implementation directions.
3. Advanced level. Create a Python 3.14 console program: enter the type run, jump, or throw and a positive result. Shared contract: ABC Event, method score(value); implementations: sample scores are 1000/seconds for Run, 100*metres for Jump, and 10*metres for Throw. Invoke operations through the shared interface and print the result. Accept up to 20 objects, validate ranges, and produce a polymorphic table without conditions on concrete types; apply the same contract checks to all implementations. Extension: rank by descending score with the same tie-breaking rule; describe the units and the educational purpose of the formulas. Add --help, named arguments, and repeatable --item with documented fields; without arguments, use keyboard input. Errors go to stderr with code 2, success with code 0. Provide totals and at least five checks, including a rejection. Annotate the methods and provide UML with inheritance or implementation directions.
Variant 21. Real estate
1. Initial level. Create a Python 3.14 console program: enter the type apartment, house, or office and an area of 1..1000 m². Shared contract: ABC Property, method value(); implementations: hypothetical prices per m² are 20000, 15000, and 25000 UAH. Invoke operations through the shared interface and print the result. Annotate the methods and provide UML with inheritance or implementation directions.
2. Basic level. Create a Python 3.14 console program: enter the type apartment, house, or office and an area of 1..1000 m². Shared contract: ABC Property, method value(); implementations: hypothetical prices per m² are 20000, 15000, and 25000 UAH. Invoke operations through the shared interface and print the result. Accept up to 20 objects, validate ranges, and produce a polymorphic table without conditions on concrete types; apply the same contract checks to all implementations. Annotate the methods and provide UML with inheritance or implementation directions.
3. Advanced level. Create a Python 3.14 console program: enter the type apartment, house, or office and an area of 1..1000 m². Shared contract: ABC Property, method value(); implementations: hypothetical prices per m² are 20000, 15000, and 25000 UAH. Invoke operations through the shared interface and print the result. Accept up to 20 objects, validate ranges, and produce a polymorphic table without conditions on concrete types; apply the same contract checks to all implementations. Extension: a catalog of up to 20 properties, sorting, and total value; implement the rate as an independent component. Add --help, named arguments, and repeatable --item with documented fields; without arguments, use keyboard input. Errors go to stderr with code 2, success with code 0. Provide totals and at least five checks, including a rejection. Annotate the methods and provide UML with inheritance or implementation directions.
Variant 22. Shape areas
1. Initial level. Create a Python 3.14 console program: enter the type disk or tile and a radius or sides of 0.1..100. Shared contract: Protocol HasArea, method area(); implementations: the unrelated classes Disk and Tile return pi*r*r and width*height. Invoke operations through the shared interface and print the result. Annotate the methods and provide UML with inheritance or implementation directions.
2. Basic level. Create a Python 3.14 console program: enter the type disk or tile and a radius or sides of 0.1..100. Shared contract: Protocol HasArea, method area(); implementations: the unrelated classes Disk and Tile return pi*r*r and width*height. Invoke operations through the shared interface and print the result. Accept up to 20 objects, validate ranges, and produce a polymorphic table without conditions on concrete types; apply the same contract checks to all implementations. Annotate the methods and provide UML with inheritance or implementation directions.
3. Advanced level. Create a Python 3.14 console program: enter the type disk or tile and a radius or sides of 0.1..100. Shared contract: Protocol HasArea, method area(); implementations: the unrelated classes Disk and Tile return pi*r*r and width*height. Invoke operations through the shared interface and print the result. Accept up to 20 objects, validate ranges, and produce a polymorphic table without conditions on concrete types; apply the same contract checks to all implementations. Extension: the shared report accepts a third independent class; demonstrate that the client needs no changes. Add --help, named arguments, and repeatable --item with documented fields; without arguments, use keyboard input. Errors go to stderr with code 2, success with code 0. Provide totals and at least five checks, including a rejection. Annotate the methods and provide UML with inheritance or implementation directions.
Variant 23. Discounted tickets
1. Initial level. Create a Python 3.14 console program: enter the type full, student, or pension and a base price of 1..1000. Shared contract: ABC Ticket, method price(); implementations: sample factors are 1 for Full, 0.5 for Student, and 0.7 for Pension. Invoke operations through the shared interface and print the result. Annotate the methods and provide UML with inheritance or implementation directions.
2. Basic level. Create a Python 3.14 console program: enter the type full, student, or pension and a base price of 1..1000. Shared contract: ABC Ticket, method price(); implementations: sample factors are 1 for Full, 0.5 for Student, and 0.7 for Pension. Invoke operations through the shared interface and print the result. Accept up to 20 objects, validate ranges, and produce a polymorphic table without conditions on concrete types; apply the same contract checks to all implementations. Annotate the methods and provide UML with inheritance or implementation directions.
3. Advanced level. Create a Python 3.14 console program: enter the type full, student, or pension and a base price of 1..1000. Shared contract: ABC Ticket, method price(); implementations: sample factors are 1 for Full, 0.5 for Student, and 0.7 for Pension. Invoke operations through the shared interface and print the result. Accept up to 20 objects, validate ranges, and produce a polymorphic table without conditions on concrete types; apply the same contract checks to all implementations. Extension: a ticket office aggregates up to 30 tickets and prints revenue and its distribution; discounts are hypothetical only. Add --help, named arguments, and repeatable --item with documented fields; without arguments, use keyboard input. Errors go to stderr with code 2, success with code 0. Provide totals and at least five checks, including a rejection. Annotate the methods and provide UML with inheritance or implementation directions.
Variant 24. Robots
1. Initial level. Create a Python 3.14 console program: enter the type wheeled, walking, or flying and a distance of 0..1000 m. Shared contract: ABC Robot, method duration(distance); implementations: sample speeds are 2, 1, and 5 m/s; time is distance/speed. Invoke operations through the shared interface and print the result. Annotate the methods and provide UML with inheritance or implementation directions.
2. Basic level. Create a Python 3.14 console program: enter the type wheeled, walking, or flying and a distance of 0..1000 m. Shared contract: ABC Robot, method duration(distance); implementations: sample speeds are 2, 1, and 5 m/s; time is distance/speed. Invoke operations through the shared interface and print the result. Accept up to 20 objects, validate ranges, and produce a polymorphic table without conditions on concrete types; apply the same contract checks to all implementations. Annotate the methods and provide UML with inheritance or implementation directions.
3. Advanced level. Create a Python 3.14 console program: enter the type wheeled, walking, or flying and a distance of 0..1000 m. Shared contract: ABC Robot, method duration(distance); implementations: sample speeds are 2, 1, and 5 m/s; time is distance/speed. Invoke operations through the shared interface and print the result. Accept up to 20 objects, validate ranges, and produce a polymorphic table without conditions on concrete types; apply the same contract checks to all implementations. Extension: a route consists of segments; a shared planner calculates the time for each robot and chooses the minimum. Add --help, named arguments, and repeatable --item with documented fields; without arguments, use keyboard input. Errors go to stderr with code 2, success with code 0. Provide totals and at least five checks, including a rejection. Annotate the methods and provide UML with inheritance or implementation directions.
Variant 25. Sample lab tests
1. Initial level. Create a Python 3.14 console program: enter the type A or B and a finite number of 0..100. Shared contract: ABC LabTest, method classify(); implementations: synthetic test A has a sample interval of 10..20, test B has 30..50; only label the result as below, within, or above. Invoke operations through the shared interface and print the result. Annotate the methods and provide UML with inheritance or implementation directions.
2. Basic level. Create a Python 3.14 console program: enter the type A or B and a finite number of 0..100. Shared contract: ABC LabTest, method classify(); implementations: synthetic test A has a sample interval of 10..20, test B has 30..50; only label the result as below, within, or above. Invoke operations through the shared interface and print the result. Accept up to 20 objects, validate ranges, and produce a polymorphic table without conditions on concrete types; apply the same contract checks to all implementations. Annotate the methods and provide UML with inheritance or implementation directions.
3. Advanced level. Create a Python 3.14 console program: enter the type A or B and a finite number of 0..100. Shared contract: ABC LabTest, method classify(); implementations: synthetic test A has a sample interval of 10..20, test B has 30..50; only label the result as below, within, or above. Invoke operations through the shared interface and print the result. Accept up to 20 objects, validate ranges, and produce a polymorphic table without conditions on concrete types; apply the same contract checks to all implementations. Extension: summarize up to 20 synthetic tests without medical conclusions; supply intervals through a component. Add --help, named arguments, and repeatable --item with documented fields; without arguments, use keyboard input. Errors go to stderr with code 2, success with code 0. Provide totals and at least five checks, including a rejection. Annotate the methods and provide UML with inheritance or implementation directions.
Variant 26. Logistics containers
1. Initial level. Create a Python 3.14 console program: enter the type standard or refrigerated, a mass of 0.1..20 t, and a temperature of -30..40. Shared contract: ABC Container, method accepts(mass, temperature); implementations: Standard accepts a mass up to 20, Refrigerated accepts up to 10 and a temperature of -20..10. Invoke operations through the shared interface and print the result. Annotate the methods and provide UML with inheritance or implementation directions.
2. Basic level. Create a Python 3.14 console program: enter the type standard or refrigerated, a mass of 0.1..20 t, and a temperature of -30..40. Shared contract: ABC Container, method accepts(mass, temperature); implementations: Standard accepts a mass up to 20, Refrigerated accepts up to 10 and a temperature of -20..10. Invoke operations through the shared interface and print the result. Accept up to 20 objects, validate ranges, and produce a polymorphic table without conditions on concrete types; apply the same contract checks to all implementations. Annotate the methods and provide UML with inheritance or implementation directions.
3. Advanced level. Create a Python 3.14 console program: enter the type standard or refrigerated, a mass of 0.1..20 t, and a temperature of -30..40. Shared contract: ABC Container, method accepts(mass, temperature); implementations: Standard accepts a mass up to 20, Refrigerated accepts up to 10 and a temperature of -20..10. Invoke operations through the shared interface and print the result. Accept up to 20 objects, validate ranges, and produce a polymorphic table without conditions on concrete types; apply the same contract checks to all implementations. Extension: add Hazardous with a capacity of 5 and a permission flag; select polymorphically without changing the cargo. Add --help, named arguments, and repeatable --item with documented fields; without arguments, use keyboard input. Errors go to stderr with code 2, success with code 0. Provide totals and at least five checks, including a rejection. Annotate the methods and provide UML with inheritance or implementation directions.
Variant 27. Classical ciphers
1. Initial level. Create a Python 3.14 console program: enter the type caesar or atbash and Latin text. Shared contract: ABC Cipher, methods encode(text) and decode(text); implementations: Caesar uses a shift of 3, Atbash mirrors A..Z and a..z and leaves other characters unchanged. Invoke operations through the shared interface and print the result. Annotate the methods and provide UML with inheritance or implementation directions.
2. Basic level. Create a Python 3.14 console program: enter the type caesar or atbash and Latin text. Shared contract: ABC Cipher, methods encode(text) and decode(text); implementations: Caesar uses a shift of 3, Atbash mirrors A..Z and a..z and leaves other characters unchanged. Invoke operations through the shared interface and print the result. Accept up to 20 objects, validate ranges, and produce a polymorphic table without conditions on concrete types; apply the same contract checks to all implementations. Annotate the methods and provide UML with inheritance or implementation directions.
3. Advanced level. Create a Python 3.14 console program: enter the type caesar or atbash and Latin text. Shared contract: ABC Cipher, methods encode(text) and decode(text); implementations: Caesar uses a shift of 3, Atbash mirrors A..Z and a..z and leaves other characters unchanged. Invoke operations through the shared interface and print the result. Accept up to 20 objects, validate ranges, and produce a polymorphic table without conditions on concrete types; apply the same contract checks to all implementations. Extension: add a third implementation with an entered shift and the contract test decode(encode(text))==text for all implementations. Add --help, named arguments, and repeatable --item with documented fields; without arguments, use keyboard input. Errors go to stderr with code 2, success with code 0. Provide totals and at least five checks, including a rejection. Annotate the methods and provide UML with inheritance or implementation directions.
Variant 28. Media library
1. Initial level. Create a Python 3.14 console program: enter the type book, audio, or video and a nonempty title. Shared contract: Protocol Borrowable, method due_days(); implementations: Book gives 14 days, Audio gives 7, and Video gives 3 as sample loan periods. Invoke operations through the shared interface and print the result. Annotate the methods and provide UML with inheritance or implementation directions.
2. Basic level. Create a Python 3.14 console program: enter the type book, audio, or video and a nonempty title. Shared contract: Protocol Borrowable, method due_days(); implementations: Book gives 14 days, Audio gives 7, and Video gives 3 as sample loan periods. Invoke operations through the shared interface and print the result. Accept up to 20 objects, validate ranges, and produce a polymorphic table without conditions on concrete types; apply the same contract checks to all implementations. Annotate the methods and provide UML with inheritance or implementation directions.
3. Advanced level. Create a Python 3.14 console program: enter the type book, audio, or video and a nonempty title. Shared contract: Protocol Borrowable, method due_days(); implementations: Book gives 14 days, Audio gives 7, and Video gives 3 as sample loan periods. Invoke operations through the shared interface and print the result. Accept up to 20 objects, validate ranges, and produce a polymorphic table without conditions on concrete types; apply the same contract checks to all implementations. Extension: a catalog of independent classes, a checkout and return log, and a shared overdue-date calculation for a given date. Add --help, named arguments, and repeatable --item with documented fields; without arguments, use keyboard input. Errors go to stderr with code 2, success with code 0. Provide totals and at least five checks, including a rejection. Annotate the methods and provide UML with inheritance or implementation directions.
Variant 29. Grading scales
1. Initial level. Create a Python 3.14 console program: enter a grade of 0..100 and the scale percent, ects, or five. Shared contract: Protocol GradeScale, method convert(score); implementations: Percent returns a number; sample ECTS thresholds are A from 90, B from 82, C from 74, D from 64, E from 60, FX from 35, F below 35; Five thresholds are 5 from 90, 4 from 74, 3 from 60, 2 below 60. Invoke operations through the shared interface and print the result. Annotate the methods and provide UML with inheritance or implementation directions.
2. Basic level. Create a Python 3.14 console program: enter a grade of 0..100 and the scale percent, ects, or five. Shared contract: Protocol GradeScale, method convert(score); implementations: Percent returns a number; sample ECTS thresholds are A from 90, B from 82, C from 74, D from 64, E from 60, FX from 35, F below 35; Five thresholds are 5 from 90, 4 from 74, 3 from 60, 2 below 60. Invoke operations through the shared interface and print the result. Accept up to 20 objects, validate ranges, and produce a polymorphic table without conditions on concrete types; apply the same contract checks to all implementations. Annotate the methods and provide UML with inheritance or implementation directions.
3. Advanced level. Create a Python 3.14 console program: enter a grade of 0..100 and the scale percent, ects, or five. Shared contract: Protocol GradeScale, method convert(score); implementations: Percent returns a number; sample ECTS thresholds are A from 90, B from 82, C from 74, D from 64, E from 60, FX from 35, F below 35; Five thresholds are 5 from 90, 4 from 74, 3 from 60, 2 below 60. Invoke operations through the shared interface and print the result. Accept up to 20 objects, validate ranges, and produce a polymorphic table without conditions on concrete types; apply the same contract checks to all implementations. Extension: three independent strategies, a gradebook with up to 30 grades, and the same boundary checks; the scales are purely educational. Add --help, named arguments, and repeatable --item with documented fields; without arguments, use keyboard input. Errors go to stderr with code 2, success with code 0. Provide totals and at least five checks, including a rejection. Annotate the methods and provide UML with inheritance or implementation directions.
Variant 30. Weather forecast
1. Initial level. Create a Python 3.14 console program: enter a day of 1..7 and two sets of 7 temperatures from -40 to 50. Shared contract: Protocol Forecast, method temperature(day); implementations: two independent local sources return values by day. Invoke operations through the shared interface and print the result. Annotate the methods and provide UML with inheritance or implementation directions.
2. Basic level. Create a Python 3.14 console program: enter a day of 1..7 and two sets of 7 temperatures from -40 to 50. Shared contract: Protocol Forecast, method temperature(day); implementations: two independent local sources return values by day. Invoke operations through the shared interface and print the result. Accept up to 20 objects, validate ranges, and produce a polymorphic table without conditions on concrete types; apply the same contract checks to all implementations. Annotate the methods and provide UML with inheritance or implementation directions.
3. Advanced level. Create a Python 3.14 console program: enter a day of 1..7 and two sets of 7 temperatures from -40 to 50. Shared contract: Protocol Forecast, method temperature(day); implementations: two independent local sources return values by day. Invoke operations through the shared interface and print the result. Accept up to 20 objects, validate ranges, and produce a polymorphic table without conditions on concrete types; apply the same contract checks to all implementations. Extension: an aggregator averages available sources, one of which may return None; print the range and number of sources, with no network access. Add --help, named arguments, and repeatable --item with documented fields; without arguments, use keyboard input. Errors go to stderr with code 2, success with code 0. Provide totals and at least five checks, including a rejection. Annotate the methods and provide UML with inheritance or implementation directions.
Procedure
- Describe the shared contract: preconditions, result, units, and expected exceptions. Draw UML before implementation.
- Choose ABC for a shared base or Protocol for independent implementations. Do not create a hierarchy just for one field.
- Implement typed classes and a polymorphic loop without a chain of concrete type checks. Call shared initialization through
superwhere the contract requires it. - Apply the same contract checks to all implementations: ordinary data, boundaries, rejections, and result type.
- For MRO or a mixin, if required by the variant, verify the order and that each step runs exactly once. For Protocol, do not limit checks to
isinstance. - Submit UML, code, a README, a table of at least five checks, and local Git history; compare the UML with the final code.
- During the defense, add a new subclass or protocol implementation without changing the report loop, and explain the substitution principle.