Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| def calculate_selling_price(daily_circulation, annual_expenses, days_sold): | |
| try: | |
| # Calculate the selling price per copy | |
| selling_price = annual_expenses / (daily_circulation * days_sold) | |
| return f"₹{selling_price:.2f} per copy" | |
| except ZeroDivisionError: | |
| return "Invalid input: Daily circulation and days sold must be greater than zero." | |
| def example_explanation(): | |
| explanation = ( | |
| "For example, if a newspaper prints 10 lakh copies daily, sells them for 360 days a year, " | |
| "and has annual expenses of ₹900 crores, the selling price per copy can be calculated as:\n\n" | |
| "Selling Price = Annual Expenses / (Daily Circulation × Days Sold)\n" | |
| "= ₹900,00,00,000 / (10,00,000 × 360)\n" | |
| "= ₹25 per copy" | |
| ) | |
| return explanation | |
| # Gradio interface | |
| interface = gr.Interface( | |
| fn=calculate_selling_price, | |
| inputs=[ | |
| gr.Number(label="Daily Circulation (e.g., 1000000 for 10 lakh copies)"), | |
| gr.Number(label="Annual Expenses (in ₹, e.g., 900000000 for ₹900 crores)"), | |
| gr.Number(label="Days Sold (e.g., 360)") | |
| ], | |
| outputs=gr.Textbox(label="Selling Price per Copy"), | |
| examples=[[1000000, 900000000, 360]], | |
| title="Newspaper Selling Price Calculator", | |
| description=( | |
| "This calculator helps determine the selling price per copy of a newspaper based on its " | |
| "daily circulation, annual expenses, and the number of days it is sold in a year.\n\n" | |
| + example_explanation() | |
| ) | |
| ) | |
| # Launch the Gradio interface | |
| interface.launch() | |