The Kidding Book — Python

Keep the goat group's books for Mbak Wiji in Python: files, CSV, encodings, classes and modules. 16 levels, played right in the browser with nothing to install.

What the levels ask

  1. The first Monday of the kidding season. Ms. Wiji makes this season’s kidding book, cempe.csv, with mulai.py, and every evening catat.py adds that day’s births. On Wednesday morning Mr. Tono clicks mulai.py again, though he meant catat.py. Choose the open mode in mulai.py so the wrong click cannot spoil the book: after Wednesday evening it must hold one header line and the four births from Monday to Wednesday.
  2. Thursday. Grandpa Rimba, the group’s animal health cadre, checks three goats, and his note for PE-03 holds a comma: batuk, pilek (a cough, a cold). periksa.py adds lines to sehat.csv, then kartu.py reads it to print the check cards. Choose how the lines are written and how they are read so all five cards print, with Grandpa’s note whole, comma and all.
  3. Friday. Mr. Wiryo, the postman, brings two new membership forms: his own, and Mrs. Ginèm’s from Krajan Hamlet with her goat, Si Cemèng. daftar.py writes them into anggota.csv, then kartu.py reads that book for the member cards and sends it to the Dinas Peternakan, which reads every file as UTF-8. Choose the encoding for writing and for reading so Mrs. Ginèm’s name arrives whole on the card and at the Dinas.
  4. Monday. The PMK vaccination round goes on: three goats were injected last Friday, nine more today, and vaksin.py skips the ones already in the book. That morning the PLN power goes out right before the fifth injection. At noon the power is back, and Ms. Wiji runs vaksin.py again. Choose how the vaccination book is written so no goat is injected twice, and Friday’s lines stay in the book.
  5. Wednesday, weighing day. Every weighing day gets one page in timbang.txt, opened with the date and always closed with its line count, so Ms. Wiji makes a class, HalamanHari, to use with with. Today Mr. Wiryo’s Si Putih (PE-05) jumps off, and the digital scale reads nothing. Fill __enter__ and __exit__ so today’s page is still closed, and the error from PE-05 still shows on the screen so it gets weighed again.
  6. Friday. The register, kambing.csv, is still in the order it was copied from Mr. Darmo’s folio book. Ms. Wiji loads it into a dict, then writes it back sorted. The pen has two goats named Si Putih: Grandma Marni’s and Mr. Wiryo’s. Choose the dict’s key so all twelve goats stay in the book.
  7. Monday. Mr. Rohim comes with the pickup for three goats a trader bought: PE-05, PE-09 and PE-12. jual.py walks every goat in the dict, records the sold ones in terjual.csv, deletes them from the dict, then writes kambing.csv again. Choose what the loop walks so all three move books and nine stay.
  8. Wednesday at dawn. Mrs. Ginèm’s Si Cemèng gives birth to three. Each kid gets a new ear tag, and the last tag number is kept in the Cempe class: 40. anting.py makes one object per kid and records it in lahir.csv. Choose how the number goes up so the three get PE-41, PE-42, PE-43, and the screen names the next tag as PE-44.
  9. Thursday. Grandpa Rimba’s Si Kuncung gives birth to two. From now on each kid is a Cempe object, and lahir.py writes each object into lahir.csv with str(c). Fill the class’s method so each book line reads date,tag,mother,sex (tanggal,tag,induk,kelamin), like yesterday’s lines.
  10. Monday. The ORF vaccine, against a goat mouth disease, is repeated every 90 days, and today is day 327 of the year. orf.py injects the goats that need it, then writes the board for tomorrow’s mantri: the ones just injected must read safe (aman). Fill perlu_vaksin so only PE-02, PE-03 and PE-06 are injected, and the board marks all six safe.
  11. Wednesday. The neighbourhood head buys Si Jalu, and three kids go into the register. A kid is a goat with one thing more, its mother: Cempe inherits from Kambing, and simpan() of Kambing writes self.baris(). Fill baris() of Cempe so a kid’s line in register.csv holds the tag, name, owner, then its mother.
  12. Friday. Grandpa Rimba brings a kid-dose dewormer. The program reads kambing.csv with Kambing.dari_baris and anak.csv with Cempe.dari_baris, then doses every object that is a kid. Complete dari_baris and the dose’s condition so the medicine goes to the three kids only.

And more, 16 levels in all.