Untitled

 avatar
unknown
python
a year ago
807 B
4
Indexable
import numpy as np

def double_money_numpy(starting_amount, days):
    days_array = np.arange(1, days + 1)

    amount = starting_amount + 2 ** (days_array - 1)

    # Print the results
    for day, money in zip(days_array, amount):
        print(f"Day {day}: ₹{money:.2f}")

# Get user input for the number of days
try:
    starting_amount = float(input("Enter the starting amount: "))
    if starting_amount < 0:
      raise ValueError("Starting amount should be greater than 0")
    num_days = int(input("Enter the number of days: "))
    if num_days < 1:
        raise ValueError("Number of days should be greater than or equal to 1.")

    # Call the function to double the money each day using NumPy
    double_money_numpy(starting_amount, num_days)

except ValueError as e:
    print(f"Error: {e}")
Editor is loading...
Leave a Comment