Python – Disposal Evaluation

HTML Program

# Disposal Evaluation Program

def get_input(prompt):
    """Utility function to get user input with validation."""
    while True:
        try:
            value = input(prompt)
            # Accepting numerical values for certain prompts
            return float(value) if prompt.startswith(("How long", "cash value", "size", "emotional value")) else value
        except ValueError:
            print("Please enter a valid input.")

def evaluate_item(use_time, next_use_time, cash_value, size, emotional_value):
    """Evaluates the item's value based on the input factors."""
    score = 0

    # Evaluation Criteria
    score = 25 - use_time
    score += (25 - next_use_time)
    score += int(cash_value / 100)
    score += (25 - size)
    score += emotional_value
    return score

def main():
    print("Disposal Evaluation Program")
    
    while True:
        # Gather information from the user
        use_time = get_input("How long has it been (in months) since you have used this item? ")
        next_use_time = get_input("How long (in months) until you think you will use this item? ")
        cash_value = get_input("What is the cash value of the item? ")
        size = get_input("How much size (in cubic feet) does the item take up? ")
        emotional_value = get_input("Rate the emotional value of the item from 1 to 50. ")

        # Convert relevant inputs to float
        cash_value = float(cash_value)
        size = float(size)
        emotional_value = float(emotional_value)
        
        # Evaluate the item
        score = evaluate_item(use_time, next_use_time, cash_value, size, emotional_value)

        # Display the score and results
        print(f"\nFinal score for the item: {int(score)}")

        # Display results
        if score > 100:
            print("\nRecommendation: Keep the item.")
        elif score < 80:
            print("\nRecommendation: Dispose of the item.")
        else:
            print("\nRecommendation: This is something you should think about.")

        # Ask the user if they want to evaluate another item or quit
        another_item = input("\nWould you like to evaluate another item? (Y/N): ").strip().lower()
        if another_item != 'y':
            print("Thank you for using the Disposal Evaluation Program. Goodbye!")
            break

if __name__ == "__main__":
    main()