Flowcharts
Flowcharts can be used to represent algorithms. Identify the flowchart symbols below.
Activity 9.2
Study this program.
# password checking
password=input("Please enter password: ")
newPassword=input("Please re-enter password: ")
if password == newPassword:
print("Access granted")
else:
print("Access denied")
Draw the flowchart for this program.
Activity 9.3
Study the flowchart.
Write a program to implement this flowchart.
Activity 9.4
Study the flowchart.
•
What does this flowchart do?
•
Write the program to implement this flowchart.
Extension: Can you extend the program to display whether they can watch 15 films or 18 films?
Activity 9.5
Boolean Operators
Complete the table using the logical (Boolean) operators AND, OR and NOT.
Symbol
|
Description
|
Returns true if both conditions are true.
| |
Returns true if any of the conditions are true.
| |
Reverses the outcome of the expression; true becomes false, false becomes true.
|
Activity 9.6
Predict the answer to the conditions and then use the interactive shell to test your answer.
Condition
|
Your prediction
(true or false?) |
Result
|
(78 == 10) or (6 == 7)
| ||
(78 == 10) or (6 == 6)
| ||
(78 == 10) and (6 == 6)
| ||
(1 < 10) and (2 < 10)
| ||
(1 < 10) or (2 < 10)
| ||
not ( 5 ==5)
| ||
not (6 < 4)
|
Hint: Try asking yourself the questions:
Is condition_1 true OR condition_2 true – if YES then the answer is true.
Is condition_1 true AND condition_2 true – if YES then the answer is true.
Activity 9.7
•
Make up some Boolean operator questions of your own and check your answers are correct by using the interactive Python shell.
Here is an example question:
>>>answer = 50
>>> (answer<40) or (answer >80)
True or False?
•
Try them out on other people. Make sure you can explain the right answer to them if they need you to.
Activity 9.8
A truth table lists all the possible combinations of true and false outcomes for each condition.
Complete the truth tables for AND and OR operators.
Truth table showing true and false AND conditions
Condition 1
|
Condition 2
|
Output
|
false
|
false
| |
true
|
false
| |
false
|
true
| |
true
|
true
|
Truth table showing true and false OR conditions
Condition 1
|
Condition 2
|
Output
|
false
|
false
| |
true
|
false
| |
false
|
true
| |
true
|
true
|
Activity 9.9
Write a program that asks the user to enter a year group and tells them which key stagethat year group is in.
Key stage
|
Year group
|
Key stage 1
|
Years 1 and 2
|
Key stage 2
|
Years 3, 4, 5 and 6
|
Key stage 3
|
Years 7, 8 and 9
|
Key stage 4
|
Years 10 and 11
|
Extension: What happens if the year group entered is greater than 11? Can you improve your program to cope with this?
Python commands colour coding
The Python language is colour coded.
Complete this table.
Colour coding
|
What does it show
|
Example
|
green
| ||
purple
| ||
black
| ||
orange
| ||
red
|
the computing hw
ReplyDeletehttps://docs.google.com/a/gillotts.org.uk/document/d/19JxeCXSfTy_PlmTbvTX5Pr0F4hrh-j4xMqv0StUH_Bg/edit?usp=sharing
Glossary homework
ReplyDeletehttps://docs.google.com/a/gillotts.org.uk/document/d/1vsVojaRrTZo7ePgay9bUZZrMOTAYhQ6xG7WElppJ3aE/edit
https://docs.google.com/a/gillotts.org.uk/document/d/1PrYjCF68axRmkSsu3FEyIwpj_NA-zchA0LRiZrA01CA/edit?usp=sharing
ReplyDeletehttps://docs.google.com/a/gillotts.org.uk/document/d/1aJ3Dte37xt1ECYdU8juu2m5wF9kpbcyKrf1FBsQxMms/edit?usp=sharing
ReplyDeletereport
My Computing Homework - Due 28th November - Jamie Legg
ReplyDeletehttps://docs.google.com/a/gillotts.org.uk/document/d/12auweNA6-7pzZ6bEsHuw8gAPVQuRl0tkCPnspK9U4Ls/edit
glossary h/w
ReplyDeletehttps://docs.google.com/a/gillotts.org.uk/document/d/1Sktbhj56ANeVmX1RTL-4GJOX0Id-eP5DicT0jym-qIQ/edit?usp=sharing
My computing HW die 28th November
ReplyDeletehttps://docs.google.com/a/gillotts.org.uk/document/d/1hUdjQ2yyp5bvuuFheqfASrsXM6yMP7-Ou-8IOG7CxtU/edit