INFO1110 Lecture Notes - Lecture 3: Floating Point, Order Of Merit
Document Summary
Exercise: write input-output tests for a program that counts the number of vowels in a string, outputting the total number of vowels, the most popular vowel, and a count of the number of times this particular vowel appears. We can write the . in and . out les depending on what we expect the output to be for any particular input. This is an example of what the input/output les could look like: To test the difference between the expected output (your . out le) and the actual out- put of your program when given a particular input (the . in le), we use the diff command. %%bash python3 program. py < test_1. in | diff - test_1. out. Do not use equality to compare oating point numbers. Floating point numbers are not precise. print(0. 1 + 0. 2) print(0. 1 + 0. 2 == 0. 3) We can assume two numbers are equal if their difference is close to zero. def is_almost_equal(a, b, error):