I recently received an assignment in class and I need help really bad.
The idea behind this assignment is to create a Network Backup Routine that that has a selection menu (New Backup Item, Remove Backup Item, Exit), I have been trying to create this program but with a sub menu to (New Backup Item and Remove Backup Item) that allows me to chose from one of the three priorities(High Priority, Medium Priority, Low Priority and an option to Return To Main Menu).
After building the menu and sub menu I need to a loop that will count the total space left for each priority
High priority has 3000MB
Medium priority has 5000MB
Low priority has 9000MB
and the user has to enter the size of his/her backup and how many times its being backed up a week which my program also needs to calculate.

I have attempted numerous times and so far nothing, it either does not work or it works only half way.

here are some of my codes that I attempted

import sys
import math

loop = 1
choice = 0
high_priority = 3000.0
med_priority = 5000.0
low_priority = 9000.0
value = 0.0,10000.0
per_week = 1,7
total_size = 0.0,9000.0
high_pri_left = 0.0,3000.0
med_pri_left = 0.0,5000.0
low_pri_left = 0.0,9000.0

def menu():

#################################################
### displays the main menu and asks for input ###
#################################################

#sets a loop so that the menu reappears after each use

exitprogram = False
while exitprogram == False:

#Displays the main menu
print(">>>>>-----------------------------------<<<<<")
print(">>>>> NETWORK BACKUP ROUTINE <<<<<")
print(">>>>>-----------------------------------<<<<<")
print("")
print("Please select an option from the menu below")
print("")
print("1. Add Backup Routine")
print("2. Remove Backup Routine")
print("3. Exit")
print("")

#Asks for an input and validates it to prevent crashing from unknown input types (i.e. string, decimal)
accepted = False
while accepted == False:
try:
choice = int(input("Please select an option using its corresponding number (e.g. 3) >>> "))
accepted = True
except:
print("")
print("INVALID INPUT. PLEASE ENTER ONE INTEGER ONLY")
print("")
accepted = False

if choice == 1:
validinputs = False
while validinputs == False:
try:
def menu():
#Display Add Backup Routine sub menu
print("")
print(">>>>>-----------------------------------<<<<<")
print(">>>>> CHOOSE BACKUP PRIORITY <<<<<")
print(">>>>>-----------------------------------<<<<<")
print("1. High Priority")
print("2. Medium Priority")
print("3. Low Priority")
print("4. Return To Main Menu")
#Asks for an input and validates it to prevent crashing from unknown input types (i.e. string, decimal)
accepted = False
while accepted == False:
try:
choice = int(input("Please select an option using its corresponding number (e.g. 3) >>> "))
accepted = True
except:
print("")
print("INVALID INPUT. PLEASE ENTER ONE INTEGER ONLY")
print("")
accepted = False

if choice == 1:
validinputs = False
while validinputs == False:
try:
value = input("What is the file size in MB? ")
per_week = input("What are the total weekly backups? ")
total_size = value * per_week
print "Total size per week is", total_size,"MB."
high_pri_left = high_priority - total_size
print "Total High Priority left", high_pri_left,"MB."

elif choice == 2:
validinputs = False
while validinputs == False:
try:
value = input("What is the file size in MB? ")
per_week = input("What are the total weekly backups? ")
total_size = value * per_week
print "Total size per week is", total_size,"MB."
med_pri_left = med_priority - total_size
print "Total Medium Priority left", med_pri_left,"MB."

elif choice == 3:
validinputs = False
while validinputs == False:
try:
value = input("What is the file size in MB? ")
per_week = input("What are the total weekly backups? ")
total_size = value * per_week
print "Total size per week is", total_size,"MB."
low_pri_left = low_priority - total_size
print "Total Low Priority left", low_pri_left,"MB."

here is one that kind of works

import sys

loop = 1
choice = 0
high_priority = 3000.0
med_priority = 5000.0
low_priority = 9000.0
value = 0.0,10000.0
per_week = 1,7
total_size = 0.0,9000.0
high_pri_left = 0.0,3000.0
med_pri_left = 0.0,5000.0
low_pri_left = 0.0,9000.0

print """Menu
1) add backup item
2) remove backup item
3) exit"""
answer = raw_input("Make a selection: ")

if "1" in answer: print """Menu
1)high priority
2)medium priority
3)low priority"""
answer = raw_input("Make a selection: ")

if choice == 1" in answer: value = input("What is the file size in MB? ")
per_week = input("What are the total weekly backups? ")
total_size = value * per_week
print "Total size per week is", total_size,"MB."
high_pri_left = high_priority - total_size
print "Total High Priority left", high_pri_left,"MB."

elif "2" in answer: value = input("What is the file size in MB? ")
per_week = input("What are the total weekly backups? ")
total_size = value * per_week
print "Total size per week is", total_size,"MB."
med_pri_left = med_priority - total_size
print "Total Medium Priority left", med_pri_left,"MB."

elif "3" in answer: value = input("What is the file size in MB? ")
per_week = input("What are the total weekly backups? ")
total_size = value * per_week
print "Total size per week is", total_size,"MB."
low_pri_left = low_priority - total_size
print "Total Low Priority left", low_pri_left,"MB."

elif "2" in answer: print """Menu
1)high priority
2)medium priority
3)low priority"""
answer = raw_input("Make a selection: ")

PLEASE HELP
THANK YOU!!

Recommended Answers

All 4 Replies

Ask specific question and post relevant, running piece of code or at least the code and clear explanation of error and what you wanted to accomplish with it. Use code tags, otherwise Python is imposible to read.

I'm a beginner and can honestly tell you I'm not even sure where to start to explain my problem.
How do I use the code tags on here?

You just push that CODE button before pasting your code between the tags produced (ctrl-V).

import sys

loop = 1
choice = 0
high_priority = 3000.0
med_priority = 5000.0
low_priority = 9000.0
value = 0.0,10000.0
per_week = 1,7
total_size = 0.0,9000.0
high_pri_left = 0.0,3000.0
med_pri_left = 0.0,5000.0
low_pri_left = 0.0,9000.0

print """Menu
1) add backup item 
2) remove backup item
3) exit"""
answer = raw_input("Make a selection: ")

if "1" in answer: print """Menu
1)high priority
2)medium priority
3)low priority"""
answer = raw_input("Make a selection: ")

if choice == 1" in answer: value = input("What is the file size in MB? ")
per_week = input("What are the total weekly backups? ")
total_size = value * per_week
print "Total size per week is", total_size,"MB."
high_pri_left = high_priority - total_size
print "Total High Priority left", high_pri_left,"MB."

elif "2" in answer: value = input("What is the file size in MB? ")
per_week = input("What are the total weekly backups? ")
total_size = value * per_week
print "Total size per week is", total_size,"MB."
med_pri_left = med_priority - total_size
print "Total Medium Priority left", med_pri_left,"MB."
                                        
elif "3" in answer: value = input("What is the file size in MB? ")
per_week = input("What are the total weekly backups? ")
total_size = value * per_week
print "Total size per week is", total_size,"MB."
low_pri_left = low_priority - total_size
print "Total Low Priority left", low_pri_left,"MB."

elif "2" in answer: print """Menu
1)high priority
2)medium priority
3)low priority"""
answer = raw_input("Make a selection: ")
import sys
import math

loop = 1
choice = 0
high_priority = 3000.0
med_priority = 5000.0
low_priority = 9000.0
value = 0.0,10000.0
per_week = 1,7
total_size = 0.0,9000.0
high_pri_left = 0.0,3000.0
med_pri_left = 0.0,5000.0
low_pri_left = 0.0,9000.0

def menu():
 
    #################################################
    ### displays the main menu and asks for input ###
    #################################################
 
    #sets a loop so that the menu reappears after each use
 
    exitprogram = False
    while exitprogram == False:
 
        #Displays the main menu
        print(">>>>>-----------------------------------<<<<<")
        print(">>>>>      NETWORK BACKUP ROUTINE       <<<<<")
        print(">>>>>-----------------------------------<<<<<")
        print("")
        print("Please select an option from the menu below")
        print("")
        print("1. Add Backup Routine")
        print("2. Remove Backup Routine")
        print("3. Exit")
        print("")
 
        #Asks for an input and validates it to prevent crashing from unknown input types (i.e. string, decimal)
        accepted = False
        while accepted == False:
            try:
                choice = int(input("Please select an option using its corresponding number (e.g. 3) >>> "))
                accepted = True
            except:
                print("")
                print("INVALID INPUT. PLEASE ENTER ONE INTEGER ONLY")
                print("")
                accepted = False
                
        if choice == 1:
            validinputs = False
            while validinputs == False:
                try:
                    def menu():
                        #Display Add Backup Routine sub menu
                        print("")
                        print(">>>>>-----------------------------------<<<<<")
                        print(">>>>>      CHOOSE BACKUP PRIORITY       <<<<<")
                        print(">>>>>-----------------------------------<<<<<")
                        print("1. High Priority")
                        print("2. Medium Priority")
                        print("3. Low Priority")
                        print("4. Return To Main Menu")
        #Asks for an input and validates it to prevent crashing from unknown input types (i.e. string, decimal)
        accepted = False
        while accepted == False:
            try:
                choice = int(input("Please select an option using its corresponding number (e.g. 3) >>> "))
                accepted = True
            except:
                print("")
                print("INVALID INPUT. PLEASE ENTER ONE INTEGER ONLY")
                print("")
                accepted = False

        if choice == 1:
            validinputs = False
            while validinputs == False:
                try:
                    value = input("What is the file size in MB? ")
                    per_week = input("What are the total weekly backups? ")
                    total_size = value * per_week
                    print "Total size per week is", total_size,"MB."
                    high_pri_left = high_priority - total_size
                    print "Total High Priority left", high_pri_left,"MB."

        elif choice == 2:
            validinputs = False
            while validinputs == False:
                try:
                    value = input("What is the file size in MB? ")
                    per_week = input("What are the total weekly backups? ")
                    total_size = value * per_week
                    print "Total size per week is", total_size,"MB."
                    med_pri_left = med_priority - total_size
                    print "Total Medium Priority left", med_pri_left,"MB."

        elif choice == 3:
            validinputs = False
            while validinputs == False:
                try:
                    value = input("What is the file size in MB? ")
                    per_week = input("What are the total weekly backups? ")
                    total_size = value * per_week
                    print "Total size per week is", total_size,"MB."
                    low_pri_left = low_priority - total_size
                    print "Total Low Priority left", low_pri_left,"MB."
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.