INFO1110 Lecture Notes - Lecture 3: Floating Point, Order Of Merit

14 views1 pages

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):

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents