Complete the following exercises in any order (although the earlier exercises should be easier).
Focus on completing the (a) exercises, as they are the basics for each exercise. You can try the extensions (b, c, etc), but don't get stuck on these for no reason. Some exercises have a program solution provided... don't check this solution until you have asked for help!
(b) Allow your name as a valid input as well.
(c) Keep track of how many times the user fails to enter the correct name, and report it when they finally get it right.
Note: You may skip this question if you haven't learned random values yet.
(b) Add the option for the user to specify how many problems they want to answer. (turing solution)
(c) Don't do a fixed number of questions. Instead, ask the user at the end of each question sequence (i.e., when they finally get it right) if they want to continue. (turing solution)
(d) Keep track of the user's attempts and the total number of questions, and then report their score (i.e., "you took X tries to answer Y questions correctly")
(e) Set a maximum number of tries for each question. When the user makes their last guess, tell them the answer an move on.
(a) Write a program to simulate a person running the 100m dash. Unfortunately, your runner isn't very consistent with their speed, and for each second of the race, they may cover from 5 to 15 metres. Report their current position each second, and the race ends when they cross the finish line.
(b) Add three additional runners (total four runners), each with their own speed which changes each second. End the race until one runner wins.
(c) Modify the program to keep running the race until ALL runners are finished. Once a runner crosses the finish line, they should stop running. If two runners cross the line in the same second, the further runner wins.
-
(b) Let the user decide which word should terminate the program. (turing solution)
(c) Add a random element where the program will refuse to display the current word. Make sure you include a message to the user. Try to make the reason funny/cryptic/technical.
(b) Add one or two additional users to your system. (turing solution)
(c) Add a security feature where there are a maximum number of failed attempts before the system locks out the login process.
(d) More security - whenever there is a valid user name with an incorrect password, track the number of failed attempts. Upon a successful login, report the number of failed attempt on their account to the user. You might want to only try this feature for a single user.
(e) Once "logged in" give the user some kind of command line prompt (e.g., "> ") and let them type anything they want. If they type "quit" (or whatever you want), exit the program. If they type "logout", return them to the log in prompt.
Collatz Conjecture: Start with any natural number, N (1, 2, 3, 4, ...). If the number is even, divide it by 2. If the number is odd, multiply by 3 then add 1. If you repeat this process enough times, the number should always reach 1. Write a program that tests this conjecture by allowing the user to enter a number, and then apply the Collatz algorithm until the number reaches 1. Show the result of each step. Hint: You will need to use the MODULO operator to determine even or odd. You may need to do some research if you haven't been taught this yet.