PythonByteSize
  • Home
  • Video Index
    • 1. The Basics
    • 2. Python Program Structures
    • 3. Python Operators
    • 4. Python Functions
    • 5. Introduction to Classes and Objects
    • 6. Python Strings
    • 7. User Defined Functions
    • 8. Classes and Objects
    • 9. Python Dictionaries
    • 10. Python tkinter
    • 11. Python Lists
    • 12. Python Namespaces
    • 13. Turtle Graphics
    • 14. Python Tips
    • 15. Complex Numbers
  • 1-Minute Videos
  • Exercise Index
    • 1. The Basics Exercises
    • 2. Python Program Structures Exercises
    • 3. Python Operators Exercises
    • 4. Python Functions Exercises
  • Donate
  • Computing Topics
  • Mathematics
  • Educators
  • Contact
  • About

Exercise 2.4. (Boundary testing the if ... else Selection Construct)


1. Ensure you have viewed the video (associated with this exercise) at this link >>

2. For the following program what is the testing boundary? What values should you enter to fully test the program? 
Exerise 2.4. Example 1

    

3. For the following specification produce a Design (Structured English or Nassi–Shneiderman Diagram), a Data Table, Test Plan with full boundary testing, and a Python program. Test your Python program against the Test Plan.

Specification
Citizens of a country who are 16 and above can vote in a referendum. Write a program that asks users to enter their age. If they are old enough to vote the program informs them that they can vote. However, if they are not old enough to vote the program tells them that they cannot vote.

Note: Use a if … else … Selection construct to implement the design and the program, also ensure that user friendly prompts are used.

4. For the following specification produce a Design (Structured English or Nassi–Shneiderman Diagram), a Data Table, Test Plan with full boundary testing, and a Python program. Test your Python program against the Test Plan.

Specification
Have a program read either a positive or negative integer entered at the keyboard by the user. The program is required to print whether the integer entered is either positive or negative. For the purpose of this exercise regard 0 (zero) as being positive. To accomodate this have the ouputs from the program be one of the following strings.
  • The number entered is either 0 or positive
  • The number entered is negative

Note: Use a if … else … Selection construct to implement the design and the program, also ensure that user friendly prompts are used.

END    Next Exercise >>

Please consider donating to help with the costs incurred in developing this website.             Donate >>