Untitled
unknown
python
2 years ago
711 B
5
Indexable
import numpy as np
def double_money_numpy(days):
# Generate an array representing each day
days_array = np.arange(1, days + 1)
# Calculate the amount for each day using exponential growth (2^x)
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:
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(num_days)
except ValueError as e:
print(f"Error: {e}")Editor is loading...
Leave a Comment