Repository with assignments using the Test Informed Learning with Examples (TILE) method to integrate testing into existing programming courses for free.
Join our LinkedIN Community.
Use the following BibTeX entry to cite this work:
@INPROCEEDINGS{DVMB2023, author={Doorn, Niels and Vos, Tanja and MarĂn, Beatriz and Barendsen, Erik}, booktitle={2023 IEEE Conference on Software Testing, Verification and Validation (ICST)}, title={Set the right example when teaching programming: Test Informed Learning with Examples (TILE)}, year={2023}, volume={}, number={}, pages={269-280}, doi={10.1109/ICST57152.2023.00033} }
We want to format a shopping list for a party with the following products: beer, wine and chips. You have to ask the user for the prices of the 3 products (we assume that they are always \(< 10\) euros), and the quantities they want to buy (we assume that they are always \(<100\) units). The program must return the purchase itemized as follows:
>>> %Run
Beer price? 9.99
Wine price? 1.05
Chips price? 4
How much beer? 99
How much wine? 23
How many bags of chips? 1
--------------------------
Total purchase
--------------------------
Beer 99 989.01
Wine 23 24.15
Chips 01 4.00
-----
Total 1017.16
You have to do 2 different implementations of your program. One
using the String module operator % to format, and another with the
str.format()
. Test your program with different prices (\(<10\)
euros) and quantities (\(<100\) units) to test that the layout is
always aligned.
```testruntile We added one sentence explicitly asking the students to test with some values and check the output.