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 3.7. (Pythons Logical Operators)


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

2. In your own words describe each of the following logical operators:

not

and
​

or
​

As part of your description use the terms condition and operands.

3. For each of the following nonsense programs (i.e. they do not implement any algorithm) write down the expected output. Once you have completed this check your answers by copying and pasting each program into your Python editor and executing them.
Exercise 3.7 Example 1

    
Exercise 3.7 Example 2

    
Exercise 3.7 Example 3

    

4. Without referring to the video write down the truth table for each of the following logical operators:
​

not

and
​

or

5. For each of the following nonsense programs (i.e. they do not implement any algorithm) write down the expected output. Once you have completed this check your answers by copying and pasting each program into your Python editor and executing them.
Exercise 3.7 Example 4

    
Exercise 3.7 Example 5

    
Exercise 3.7 Example 6

    

6. Write a computer program to implement the following specification.

Specification
A bank will offer a customer a loan if they are 21 or over and have an annual income of at least £21000. The customers age and income are input in response to user friendly prompts. One of the following strings are printed on the Visual Display Unit dependant on the condition of an if ... else ... selection construct:

We are able to offer you a loan.

Unfortunately at this time we are unable to offer you a loan.


​

END    Next Exercise >>

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