In: Computer Science
I am trying to make a Risk Management tool in Python. I have it partially started. The scenario is that the Project Manager needs to be able to log on and enter information ( the required information is located in the code). I then need to capture that data and store it in an array with the ability to call back and make changes if necessary. Could you please help me out and explain what was done?
Current code:
Start of Code:
import os
import numpy
# Clear Screen
clear = lambda: os.system ('cls')
while True:
# Clear Screen
clear()
# Username and Password input from user
username = input("Enter Username: ")
Password = input("Enter Password: ")
# Checks user input against known users
if username == "Teague" and Password == "Pre$c0tt966":
break
if username == "David" and Password == "W0lvert0n354":
break
if username == "Seth" and Password == "D0ugl@s537":
break
if username == "Mike" and Password == "Tunber&156":
break
if username == "Kim" and Password == "Hu&nh565":
break
# Clear Screen
clear()
print ("Login Succesful!")
while True:
menu = input("Press 'p' for project setup: ")
name = ['-']
date = ['-']
risk = ['-']
likelihood = ['-']
consequences = [0.0]
percentage = [0.0]
riskstate = [0.0]
x = 0
if menu == 'p':
clear()
while True:
name[x] = input("Enter Project Name: ")
date[x] = input("Enter Project Date: ")
risk[x] = input("Enter Risk Name:")
likelihood[x] = input("Enter Likelihood of Risk (A-E): ")
if likelihood == "A":
likelihood = 0.1
if likelihood == "B":
percentage = 0.3
if likelihood == "C":
percentage = 0.5
if likelihood == "D":
percentage = 0.7
if likelihood == "E":
percentage = 0.9
consequences[x] = input("Enter Consequence Level (1-5): ")
riskstate[x] = percentage * consequences
if Like == 0.1:
state = "low"
if Like == 0.3 and Con < 3:
state = "low"
if Like == 0.3 and Con > 3:
state = "medium"
if Like == 0.5 and Con < 3:
state="low"
if Like == 0.5 and Con < 5:
state = "medium"
if Like == 0.5 and Con == 5:
state = "high"
if Like == 0.7 and Con < 2:
state="low"
if Like == 0.7 and Con< 4:
state ="medium"
if Like == 0.7 and Con> 4:
state="high"
if Like == 0.9 and Con < 3:
state="medium"
if Like == 0.9 and Con > 3:
state="high"
x+1
break
print(name[0])
Summary-
Initially clear screen is put in a true loop so that the user is prompted to enter their username and password.
Then if the username and passwords are matched with the existing users, break condition is given describing to come out of the loop. But there is a disadvantage here: even if the username and passwords aren't matched with the existing credentials, the controls comes to the print statement logon successful and then the control shifts there, prompting the user to enter project setup. Therefore something like return statement must be specified for the mismatched credentials.
After the logon, the user is prompted with the statement to enter into project setup, further inputting project name, project date, risk name, likelihood of risk, consequence level. There is a wrong statement for the likelihood of risk: Where the program has conditions:
if likelihood == "A":
likelihood = 0.1
if likelihood == "B":
percentage = 0.3
if likelihood == "C":
percentage = 0.5
if likelihood == "D":
percentage = 0.7
if likelihood == "E":
percentage = 0.9
This should be changed to likelihood[x]. Because the specified term in the array should be compared.
Then there are conditions for the risk state, which is not being outputted anywhere. then x is being incremented to the next index further saving the values in the next indices, which should be :
x += 1 (instead of x=1)
Then at last name[0] is being printed. (which is the project name)
Please revert back with comments, if there are any doubts. I am happy to help.
Thank you.