250 likes | 273 Views
PYTHON TIMES TABLE 4. This is the last code we saved. It deals correctly with both x and x*y single and double numbers. PYTHON TIMES TABLE 4. How does it handle triple number answers?. PYTHON TIMES TABLE 4. How does it handle triple number answers? They don’t format properly.
E N D
PYTHON TIMES TABLE 4 This is the last code we saved. It deals correctly with both x and x*y single and double numbers.
PYTHON TIMES TABLE 4 How does it handle triple number answers?
PYTHON TIMES TABLE 4 How does it handle triple number answers? They don’t format properly.
PYTHON TIMES TABLE 4 We need to deal with the triple answer numbers as we did with the x double numbers but….
PYTHON TIMES TABLE 4 But first… Have we dealt with the single and double y numbers? Run the 9 times table then try 10, 11 and 12 times tables. Is there a formatting problem?
PYTHON TIMES TABLE 4 With the 10, 11 and 12 times tables there does not appear to be a formatting problem with y number. What is the reason?
PYTHON TIMES TABLE 4 With the 10, 11 and 12 times tables there does not appear to be a formatting problem with y number. What is the reason? It is simply because the y value does not change throughout the table. So No change – No action
PYTHON TIMES TABLE 4 The only major formatting problem now occurs when the x*y answer changes from a double to a triple number ie. When it exceeds 99. Lets have a go.
PYTHON TIMES TABLE 4 When you are dealing with a problem the first step is always to try and find out exactly what is definitely NOT causing a problem i.e. what is NOT wrong so we can try and see just what is left which could be causing the problem.
PYTHON TIMES TABLE 4 We have already found that the problems of formatting triple figure x*y answer numbers first occurs in the 9 times table when 12 x 9 = 108. Which tables therefore are formatting correctly?
PYTHON TIMES TABLE 4 A suggestion is firstly let 2 to 8 times table run normally and then we will deal with the 9 times table How do we allow only the 2 to 8 times to run?
PYTHON TIMES TABLE 4 A suggestion is firstly let 2 to 8 times table run normally and then we will deal with the 9 times table How do we allow only the 2 to 8 times to run? Change while x <= 12: to:- while x <= 12 and y <=8:
PYTHON TIMES TABLE 4 The original was:- while x <= 12: Which we have now changed to:- while x <= 12 and y <=8:
PYTHON TIMES TABLE 4 The original was:- while x <= 12: Which we have now changed to:- while x <= 12 and y <=8: and is the second logic term; the first was the if term.
PYTHON TIMES TABLE 4 The original was:- while x <= 12: Which we have now changed to:- while x <= 12 and y <=8: and is the second logic term; the first was the if term. There are more logic terms:-
PYTHON TIMES TABLE 4 A fuller list of logic terms is:- if testing of certain values and both values must be true or either value must be true NOT the value must NOT be true
PYTHON TIMES TABLE 4 A fuller list of logic terms is:- if testing of certain values and both values must be true or either value must be true NOT the value must NOT be true What is the opposite of TRUE?
PYTHON TIMES TABLE 4 A fuller list of logic terms is:- What is the opposite of TRUE? The opposite of TRUE is FALSE. TRUE and FALSE could be shown as ONE, 1 and ZERO, 0.
PYTHON TIMES TABLE 4 A fuller list of logic terms is:- What is the opposite of TRUE? The opposite of TRUE is FALSE. TRUE and FALSE could be shown as ONE, 1 and ZERO, 0. Computers use 0’s and 1’s.
PYTHON TIMES TABLE 4 Now that only the 2 to 8 times tables are allowed to run, we can start to have a go at formatting the 9 times table:-
PYTHON TIMES TABLE 4 Now that only the 2 to 8 times tables are allowed to run, we can start to have a go at formatting the 9 times table:- Copy the complete original if term and paste it below the original.
PYTHON TIMES TABLE 4 x = 1 y = 9 while x <= 12 and y <=8: # This deals with 2 to 8 times tables if x*y <=9: print ( ' ', x, 'x', y, '= ', x*y) elif x <=9: print ( ' ', x, 'x', y, '=', x*y) elif x >= 10: print ( ' ', x, 'x', y, '=', x*y) x = x + 1 while x <= 11 and y ==9: # This deals with 1 x 9 to 11 x 9 only if x*y <=9: print ( ' ', x, 'x', y, '= ', x*y) elif x <=9: print ( ' ', x, 'x', y, '= ', x*y) elif x >= 10: print ( ' ', x, 'x', y, '= ', x*y) x = x + 1 while x == 12 and y ==9: # This deals when 12 x 9 = 108 print ( ' ', x, 'x', y, '=', x*y) x = x + 1
PYTHON TIMES TABLE 4 Try the code with the 10 times table followed by the 11 times table. Next try the 12 times table.
PYTHON TIMES TABLE 4 Try the code with the 10 times table followed by the 11 times table. Next try the 12 times table. You will find that there is a problem with the 9 x 12 = 108. Its just the same as 12 x 9 = 108 yet again! I will leave it to you!
PYTHON TIMES TABLE 4 This is the end of TIMES TABLE 4