AI Ustoz UZ: learn artificial intelligence in Uzbek

A small project: a task list

Intermediate level · lesson 5 · about 15 min

Now we combine all the steps in one small project: you write a spec, get (or write) the code, read it, test it, fix it. The project: a task list. Each task is a dictionary: a name and a mark for whether it is done.

sonlar = []
sonlar.append(5)
sonlar.append(8)
print(len(sonlar))
print(sonlar[0])
Output2
5

list.append(x) adds an item to a list. A function can change a list that lives outside the function. Below is an example of adding values to a list.

The work starts from a spec: add, mark as done, get the ones left. After writing each function, test it with an example. You may write the project with the help of artificial intelligence, but read and test the result yourself.

Remember

  • Project = spec + code + reading + testing + fixing.
  • list.append(x) adds an item.
  • Test every function with an example.

Exercise

Artificial intelligence instantly gave you the code for the whole project. Which is the right way?

Answer and explanation
  1. Read it in parts and test each part with an example. (correct answer)in small parts a bug is easier to find.
  2. Give it to users without testing.the bugs will reach the users.
  3. Skip reading it and trust the message “it worked”.running does not guarantee correctness.

Code exercises

  1. Write the task list: qosh(nom) adds a task (a dictionary with nom and bajarildi), bajar(nom) marks it done, qolgan() returns a list of the names of tasks not done.
    Hint: Each task is a dictionary {"nom": nom, "bajarildi": False}. In qolgan() loop and append to a new list the names of those whose bajarildi is false.

Do the exercise in the app.

Practical task

Add one new feature to the project (for example, deleting a task) and test it with 2 examples.

  • I added the feature
  • I tested it with 2 examples

Glossary

Interactive mode: search, progress and Python exercises.