This program makes use of the creation of modulo arithemtic as well as simple file handling, such as writing the scores to file, and then sorting the file
What is Modulo arithmetic? Well, this university challenge video may get your juices flowing and wanting to know more!
Read the task instructions that are included in the comments in the code, and then get started!
You can either edit and code online in repl.it or alternatively, you can simply cut and paste the below into your own python file
Solve the challenge on repl.it""" ==============TASK If a user wants to be inspired by some modulo magic, they need to first register and then login. The modulo magic function has been created already, but you need to code the login and register subroutines that the user must get through before getting to the magic! 1. Register - allow a user to sign up with a username and password 2. These details are written to a file called logininfo.txt 3. When logging in, the user must enter their username and password and it should match the file records """ def mainmenu(): print(""" =========MAIN MENU========""") print("+-------------------------------------+") print("| Please select an option: |") print("| 1 - Register |") print("| 2 - Login |") print("| 3- Quit |") print("----------------------------------------") def magic() #solution to modulo arithemetic magic using lists days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] enterday=input("Enter day of week:") enternumber=input("Enter no. of days:") day_number = days.index(enterday) offset = enternumber print(days[(day_number + int(offset)) % 7]) mainmenu()
Check out these two videos- more on modulo arithmetic and a google interview. What does it have to do with modulo arithmetic?
A sample flow chart (design) for this particular challenge could look like:
Test No. | Description | Test Data(input) | Expected Outcome | Actual Outcome | Further Action? |
---|---|---|---|---|---|
1 | |||||
2 | |||||
3 | |||||
4 | |||||
5 |