Question

In: Computer Science

I am trying to make a Risk Management tool in Python. I have it partially started....

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])

Solutions

Expert Solution

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.


Related Solutions

I am trying to make a program in Python that opens a file and tells you...
I am trying to make a program in Python that opens a file and tells you how many lines, vowels, consonants, and digits there are in the file. I got the print out of lines, digits, and consonants, but the if statement I made with the vowels list isn't recognizing them. How can I make the vowels go through the if statement with the list? Am I using the wrong operator? Here is my program #Assignment Ch7-1 #This program takes...
Working with Python. I am trying to make my code go through each subject in my...
Working with Python. I am trying to make my code go through each subject in my sample size and request something about it. For example, I have my code request from the user to input a sample size N. If I said sample size was 5 for example, I want the code to ask the user the following: "Enter age of subject 1" "Enter age of subject 2" "Enter age of subject 3" "Enter age of subject 4" "Enter age...
This is my code for python. I am trying to do the fourth command in the...
This is my code for python. I am trying to do the fourth command in the menu which is to add an employee to directory with a new phone number. but I keep getting error saying , "TypeError: unsupported operand type(s) for +: 'dict' and 'dict". Below is my code. What am I doing wrong? from Lab_6.Employee import * def file_to_directory(File): myDirectory={}       with open(File,'r') as f: data=f.read().split('\n')    x=(len(data)) myDirectory = {} for line in range(0,199):      ...
BioChem Question I am trying to make a phosphate buffer, but I only have monoprotic potassium...
BioChem Question I am trying to make a phosphate buffer, but I only have monoprotic potassium phosphate. Should I expect the pH to be low or high once I dissolve the solid in water? Does this mean I should expect to need acid or base to adjust the pH to 7.0? Would formic acid or acetic acid be a better buffer at pH 5.0? Why? Which buffer would be my best choice if I need my reaction to be run...
I am trying to make a new code that uses functions to make it. My functions...
I am trying to make a new code that uses functions to make it. My functions are below the code. <?php */ $input; $TenBills = 1000; $FiveBills = 500; $OneBills = 100; $Quarters = 25; $Dimes = 10; $Nickels = 5; $Pennies = 1; $YourChange = 0; $input = readline("Hello, please enter your amount of cents:\n"); if(ctype_digit($input)) { $dollars =(int)($input/100); $cents = $input%100;    $input >= $TenBills; $YourChange = (int)($input/$TenBills); $input -= $TenBills * $YourChange; print "Change for $dollars dollars...
Using Python, I am trying to integrate 'iloc' into the line of code below? This line...
Using Python, I am trying to integrate 'iloc' into the line of code below? This line is replacing all the '1' values across my .csv file and is throwing off my data aggregation. How would I implement 'iloc' so that this line of code only changes the '1's integers in my 'RIC' column? patient_data_df= patient_data_df.replace(to_replace=[1], value ="Stroke") Thank you:)
I am trying to implement a search function for a binary search tree. I am trying...
I am trying to implement a search function for a binary search tree. I am trying to get the output to print each element preceding the the target of the search. For example, in the code when I search for 19, the output should be "5-8-9-18-20-19" Please only modify the search function and also please walk me through what I did wrong. I am trying to figure this out. Here is my code: #include<iostream> using namespace std; class node {...
I am trying to make a temperature warning system in LabVIEW. given temperature T, I want...
I am trying to make a temperature warning system in LabVIEW. given temperature T, I want a green light to turn on when temperature is less than 75 degrees. when the temperature is between 75 and 90 degrees, i want a yellow light to turn on. when the temperature is greater than 90 degrees, I want a red light indicator to turn on. how would this case structure look like in LabVIEW?
I am having a trouble with a python program. I am to create a program that...
I am having a trouble with a python program. I am to create a program that calculates the estimated hours and mintutes. Here is my code. #!/usr/bin/env python3 #Arrival Date/Time Estimator # # from datetime import datetime import locale mph = 0 miles = 0 def get_departure_time():     while True:         date_str = input("Estimated time of departure (HH:MM AM/PM): ")         try:             depart_time = datetime.strptime(date_str, "%H:%M %p")         except ValueError:             print("Invalid date format. Try again.")             continue        ...
I have sequences of 128X128 images of faces saved in a folder. I am trying to...
I have sequences of 128X128 images of faces saved in a folder. I am trying to create a pytorch dataloader that will load the image sequences along with its timestamps and average heart rate value. The Dataloader to loads the data(e.g., 128 video frames X, 128 points-timesteps Y, average heart rate value H) as tensors. Then forward it to forward the model. I am new to pytorch and I am not sure how to create data loaders with pytorch and...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT