-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path10. fruit_vegetable_count.py
34 lines (25 loc) · 1.08 KB
/
10. fruit_vegetable_count.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
'''
Print the number of fruits and vegetables we eat in a day given fruit_count and vegetable_count
'''
def fr_veg_count ( a: int, b: int )-> int:
"""
Takes the number of fruits and vegetable consumed and prints it given a and b.
Args:
a(int): the fruit_count.
b(int): the vegetable_count.
Returns:
str: output declaring the number of fruit and vegetable consumed.
"""
return(f"The number of fruit consumed is {a} and the number of vegetable consumed is {b}.")
# Using try- except for handling possible KeybaordInterrupt error from user
try:
# Enter number of fruit
fruit_count: int= int(input("Enter number of fruit:- "))
# Enter number of vegetable
vegetable_count: int= int(input("Enter number of vegetable:- "))
# Formulating a variable containing no. of fruit and vegetable consumed using fr_veg_count function
total_count:int= fr_veg_count(fruit_count, vegetable_count)
# Printing the value
print(total_count)
except KeyboardInterrupt as e:
print(f"Error: User terminated the program beforehand.")