AI Ustoz UZ: learn artificial intelligence in Uzbek

Vibe coding and a precise spec

Intermediate level · lesson 1 · about 12 min

Vibe coding is a way of building a program by talking with artificial intelligence: you say what you need and the tool proposes code. But responsibility for the code stays with you: if you do not check that it works correctly, you cannot rely on it. The result depends on how precisely the task is written.

A precise spec has four parts: what goes in (input), what should come out (output), 2–3 concrete examples and edge cases (for example an empty list, 0 or the largest value). For choosing by a condition Python has if, elif, else. The line after the condition is also indented by 4 spaces.

yosh = 20
if yosh >= 18:
    print("kattalar")
else:
    print("bolalar")
Outputkattalar

Edge cases are where mistakes happen most often. For example, if you write “adults over 18”, say clearly whether a person who is exactly 18 counts as an adult. Precise examples make both the spec and the later testing easier.

Remember

  • Vibe coding: you give the task, checking the code stays with you.
  • Spec = input + output + examples + edge cases.
  • Condition: if, elif, else.

Exercise

Which of these is a good spec?

Answer and explanation
  1. “Write me a function that checks age.”the input, output and limits are unknown.
  2. “The function yosh_toifa(yosh) returns bola for ages under 18, kattalar for 18–64 and keksa for 65 and over. Example: 10 → bola, 65 → keksa.” (correct answer)the input, output, limits and examples are given.
  3. “Make the code beautiful.”beauty is not a checkable criterion.

Code exercises

  1. Write the function yosh_toifa(yosh): it returns bola for ages under 18, kattalar for 18 to 64 and keksa for 65 and over.
    Hint: if yosh < 18:, then elif yosh < 65:, and else: at the end. return in each branch.

Do the exercise in the app.

Practical task

Write a spec for a small function (for example, deciding whether a number is even): input, output and 3 examples, including one edge case.

  • I wrote the input and output
  • I wrote 3 examples
  • I added one edge case

Glossary

Interactive mode: search, progress and Python exercises.