imir.io/projects/c3827df7-3cf3-4311-80ae-a36faf63acef/project submissions Write
ID: 3729296 • Letter: I
Question
imir.io/projects/c3827df7-3cf3-4311-80ae-a36faf63acef/project submissions Write a program to fetch state of residence and marital status of 5 users. Use if.elif: to find out the number of people who belong to each of the regions below. If the user is from "CA", “NV",-AR", "WA". count them towards westernregion Within this region, count the number of people who are married, single, divorced and separated. If the user is from "NY", "MA", "FL count them towards eastern region Within this region, count the number of people who are married, single, divorced and separated. If the user is from "TX", "AL", "GA count them towards southern region Within this region, count the number of people who are married, single, divorced and separated. ELSE AR or WA" Make sure you test the program intensively before submitting it. All results must be displayed Mimir Requirements: display "The person is not counted towards Any of the following states. TX, Al, GA, NY, MA, FL, CA, NV. The file name should be named Module3Homework5.py Your program should be able to handle both cases for each state, fo example, CA or "ca for california, TX" or tx" for Texas and so on. Similarly, for marital status, your program should handle status "Married" or "married "Single" or 'single and so on. Mimir will be testing your program for different variations of input with multiple test cases. Your program must pass each test case scenario. Here are the results of three sample scenarios. Test Scenario 1 please enter the state where the first person resides:CA Please enter your marital status of first person :'Single please enter the state where the second person resides :TX Please enter your marital status of second person :Divorced please enter the state where the third person resides :FL 2Explanation / Answer
Please the below written python3 code for the problem asked. The code is working perfectly fine as I've checked it with many test cases.
Save the file as 'Module3Homework5.py'
wr = 0
er = 0
sr = 0
wr_m = 0
wr_s = 0
wr_d = 0
wr_sp = 0
er_m = 0
er_s = 0
er_d = 0
er_sp = 0
sr_m = 0
sr_s = 0
sr_d = 0
sr_sp = 0
state = input('Please enter the state where the first person resides:').upper()
ms = input('Please enter the marital status of the first person:').upper()
if state == 'CA' or state == 'NV' or state == 'AR' or state == 'WA':
wr += 1
if ms == 'SINGLE':
wr_s += 1
elif ms == 'MARRIED':
wr_m += 1
elif ms == 'DIVORCED':
wr_d += 1
else:
wr_sp += 1
elif state == 'NY' or state == 'MA' or state == 'FL':
er += 1
if ms == 'SINGLE':
er_s += 1
elif ms == 'MARRIED':
er_m += 1
elif ms == 'DIVORCED':
er_d += 1
else:
er_sp += 1
elif state == 'TX' or state == 'AL' or state == 'GA':
sr += 1
if ms == 'SINGLE':
sr_s += 1
elif ms == 'MARRIED':
sr_m += 1
elif ms == 'DIVORCED':
sr_d += 1
else:
sr_sp += 1
else:
print('The person is not counted towards any of the following states. TX,AL,GA,NY,MA,FL,CA,NV,AR or WA')
state = input('Please enter the state where the second person resides:').upper()
ms = input('Please enter the marital status of the second person:').upper()
if state == 'CA' or state == 'NV' or state == 'AR' or state == 'WA':
wr += 1
if ms == 'SINGLE':
wr_s += 1
elif ms == 'MARRIED':
wr_m += 1
elif ms == 'DIVORCED':
wr_d += 1
else:
wr_sp += 1
elif state == 'NY' or state == 'MA' or state == 'FL':
er += 1
if ms == 'SINGLE':
er_s += 1
elif ms == 'MARRIED':
er_m += 1
elif ms == 'DIVORCED':
er_d += 1
else:
er_sp += 1
elif state == 'TX' or state == 'AL' or state == 'GA':
sr += 1
if ms == 'SINGLE':
sr_s += 1
elif ms == 'MARRIED':
sr_m += 1
elif ms == 'DIVORCED':
sr_d += 1
else:
sr_sp += 1
else:
print('The person is not counted towards any of the following states. TX,AL,GA,NY,MA,FL,CA,NV,AR or WA')
state = input('Please enter the state where the third person resides:').upper()
ms = input('Please enter the marital status of the third person:').upper()
if state == 'CA' or state == 'NV' or state == 'AR' or state == 'WA':
wr += 1
if ms == 'SINGLE':
wr_s += 1
elif ms == 'MARRIED':
wr_m += 1
elif ms == 'DIVORCED':
wr_d += 1
else:
wr_sp += 1
elif state == 'NY' or state == 'MA' or state == 'FL':
er += 1
if ms == 'SINGLE':
er_s += 1
elif ms == 'MARRIED':
er_m += 1
elif ms == 'DIVORCED':
er_d += 1
else:
er_sp += 1
elif state == 'TX' or state == 'AL' or state == 'GA':
sr += 1
if ms == 'SINGLE':
sr_s += 1
elif ms == 'MARRIED':
sr_m += 1
elif ms == 'DIVORCED':
sr_d += 1
else:
sr_sp += 1
else:
print('The person is not counted towards any of the following states. TX,AL,GA,NY,MA,FL,CA,NV,AR or WA')
state = input('Please enter the state where the fourth person resides:').upper()
ms = input('Please enter the marital status of the fourth person:').upper()
if state == 'CA' or state == 'NV' or state == 'AR' or state == 'WA':
wr += 1
if ms == 'SINGLE':
wr_s += 1
elif ms == 'MARRIED':
wr_m += 1
elif ms == 'DIVORCED':
wr_d += 1
else:
wr_sp += 1
elif state == 'NY' or state == 'MA' or state == 'FL':
er += 1
if ms == 'SINGLE':
er_s += 1
elif ms == 'MARRIED':
er_m += 1
elif ms == 'DIVORCED':
er_d += 1
else:
er_sp += 1
elif state == 'TX' or state == 'AL' or state == 'GA':
sr += 1
if ms == 'SINGLE':
sr_s += 1
elif ms == 'MARRIED':
sr_m += 1
elif ms == 'DIVORCED':
sr_d += 1
else:
sr_sp += 1
else:
print('The person is not counted towards any of the following states. TX,AL,GA,NY,MA,FL,CA,NV,AR or WA')
state = input('Please enter the state where the fifth person resides:').upper()
ms = input('Please enter the marital status of the fifth person:').upper()
if state == 'CA' or state == 'NV' or state == 'AR' or state == 'WA':
wr += 1
if ms == 'SINGLE':
wr_s += 1
elif ms == 'MARRIED':
wr_m += 1
elif ms == 'DIVORCED':
wr_d += 1
else:
wr_sp += 1
elif state == 'NY' or state == 'MA' or state == 'FL':
er += 1
if ms == 'SINGLE':
er_s += 1
elif ms == 'MARRIED':
er_m += 1
elif ms == 'DIVORCED':
er_d += 1
else:
er_sp += 1
elif state == 'TX' or state == 'AL' or state == 'GA':
sr += 1
if ms == 'SINGLE':
sr_s += 1
elif ms == 'MARRIED':
sr_m += 1
elif ms == 'DIVORCED':
sr_d += 1
else:
sr_sp += 1
else:
print('The person is not counted towards any of the following states. TX,AL,GA,NY,MA,FL,CA,NV,AR or WA')
print(' The number of people who belong to Western region is:{}'.format(wr))
print('The number of people who are married in Western region is:{}'.format(wr_m))
print('The number of people who are single in Western region is:{}'.format(wr_s))
print('The number of people who are divorced in Western region is:{}'.format(wr_d))
print('The number of people who are separated in Western region is:{} '.format(wr_sp))
print('The number of people who belong to Eastern region is:{}'.format(er))
print('The number of people who are married in Eastern region is:{}'.format(er_m))
print('The number of people who are single in Eastern region is:{}'.format(er_s))
print('The number of people who are divorced in Eastern region is:{}'.format(er_d))
print('The number of people who are separated in Eastern region is:{} '.format(er_sp))
print('The number of people who belong to Southern region is:{}'.format(sr))
print('The number of people who are married in Southern region is:{}'.format(sr_m))
print('The number of people who are single in Southern region is:{}'.format(sr_s))
print('The number of people who are divorced in Southern region is:{}'.format(sr_d))
print('The number of people who are separated in Southern region is:{}'.format(sr_sp))
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.