Question: Write a Python program that does the following specified tasks based on user input: 1 . The user inputs the name of a region in

Write a Python program that does the following specified tasks based on user input:
1. The user inputs the name of a region in the format "city,province" format e.g.(Toronto,Ontario). The program extracts the first letter of the city name and the first letter of the province name to create a unique region code. Both letters are capitalized (e.g., "Toronto,Ontario" yields the code "TO").
2. The user inputs the total amount of rainfall in millimeters as an integer (e.g.,15 mm).The program classifies the rainfall amount based on predefined categories:
Light for rainfall <=5 mm
Moderate for 5< rainfall <=20 mm
Heavy for 20< rainfall <=50 mm
Extreme for rainfall >50 mm
The program then outputs both the region code and the classification of the rainfall.
You may assume the region name is always in the format "city,province" and that the rainfall amount is a positive integer.
Sample Run 1:
Enter region: Edmonton,Alberta
Enter rainfall: 45
EA
Heavy
Sample Run 2:
Enter region: toronto,ontario
Enter rainfall: 7
TO
Moderate

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!