Learning Intentions
TBAT: use a range of Variables, IF and ELIF statements effectively
Success Criteria
To improve a working program that checks for a correct username and password combination and gives user feedback as to incorrect input
TBAT: use a range of Variables, IF and ELIF statements effectively
Success Criteria
To improve a working program that checks for a correct username and password combination and gives user feedback as to incorrect input
Click on the test button link and complete the test exercise. When finished take a screen shot & copy into a word document. Add your name to a header and give the document a title of "Python Terms". Save the document but don't close it down.
|
Questions?????
What outcomes did the simple username & password flowchart have?
What feature of iteration / repetition was added to the improved flowchart ?
EBI
The previous code is only useful if there are only two possible outcomes. What if we want to tell the user if they got their username wrong or their password wrong? TASK: Amend your code so that if the user enters either the username or the password incorrectly it outputs an appropriate alert message.
Hint - you will need to use IF, ELIF & ELSE this time, the IF part does not need to be changed |
Moving on - Iteration
Iteration just means repetition, there are many times when you find yourself giving the same instruction repeatedly. Iteration is used to tell the computer’s hardware to follow the same instruction a number of times. Programming languages use Loops to repeat an instruction.
Loops save having to repeatedly write out the same instruction which in turn means you are less likely to make mistakes in your program. The ability to repeatedly carry out the same instruction and do it identically each time is one of the most powerful properties of computer systems.
Programming languages typically implement two different methods of Iteration.
FOR Loops and
WHILE Loops.
Iteration just means repetition, there are many times when you find yourself giving the same instruction repeatedly. Iteration is used to tell the computer’s hardware to follow the same instruction a number of times. Programming languages use Loops to repeat an instruction.
Loops save having to repeatedly write out the same instruction which in turn means you are less likely to make mistakes in your program. The ability to repeatedly carry out the same instruction and do it identically each time is one of the most powerful properties of computer systems.
Programming languages typically implement two different methods of Iteration.
FOR Loops and
WHILE Loops.
Your next task
Add comments to your code to explain what each line does. Can you make any improvements to the code? Look at what others have done was their code better?
Add a screen shot of your code to the python terms document, put your name in a header, save and print out. Put into your folder
Add a screen shot of your code to the python terms document, put your name in a header, save and print out. Put into your folder