Continue onto Chapter 4 questions:
1
- >>> 5 % 2
4
- >>> 9 % 5
3
- >>> 15 % 12
12
- >>> 12 % 15
0
- >>> 6 % 6
0
- >>> 0 % 7
integer division or modulo by zero is the end result I get when i try to put 7%0 into python. Python does this because it cant get 7% of 0 when 0 has nothing in it.
- >>> 7 % 0
#2: make a program
p q not p or q ===================== True True True True False True False True True False False False
p q p and q
======================
True True True
True False False
False True False
False False False
p q not p and q
==========================
True True False
True False False
False True True
False False False
p q not(p) or not(q)
============================
True True True
True False False
False True True
False False True
p q not(p) and not(q)
============================
True True True
True False False
False True True
False False True
After a few minutes I figured what they meant by changing "p or q" to stuff like "not p and not q".
#4:
Excellent! These logical expressions are central to computer program, since computers are essentially "logic calculators".
ReplyDeleteYour last comment is particular encouraging, since it means you really "get it". You critically evaluated what you saw and created your own "test" to make sure your understanding matched the behavior of the system.