File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change
1
+ def calculate_split (total_amount : float , number_of_people : int , currency : str ) -> None :
2
+ if number_of_people < 1 :
3
+ raise ValueError ('Number of people should be at least one.' )
4
+
5
+ # Calculate the share per person
6
+ share_per_person : float = total_amount / number_of_people
7
+
8
+ # Print the results
9
+ print (f'Total expenses: { currency } { total_amount :,.2f} ' )
10
+ print (f'Number of people: { number_of_people } ' )
11
+ print (f'Each person should pay: { currency } { share_per_person :,.2f} ' )
12
+
13
+
14
+ def main () -> None :
15
+ try :
16
+ # Input for total amount
17
+ total_amount : float = float (input ('Enter the total amount of the expense: ' ))
18
+
19
+ # Input for number of people
20
+ number_of_people : int = int (input ('Enter the number of people sharing the expense: ' ))
21
+
22
+ # Call the function to calculate the split with currency set to rupees
23
+ calculate_split (total_amount , number_of_people , currency = "₹" )
24
+
25
+ except ValueError as e :
26
+ print (f'Error: { e } ' )
27
+
28
+
29
+ # Run the main function
30
+ if __name__ == "__main__" :
31
+ main ()
Original file line number Diff line number Diff line change
1
+ Python 3.12.3
You can’t perform that action at this time.
0 commit comments