Computer Science, asked by jiyarajput843, 4 months ago

- You should take Arunachal Pradesh / Meghalaya as one of
the five states. The project will perform following functionality using a
menu driven program:
Covid -19 cases in Five States/ Union Territories
------------------------------------------------------------
1. Show Total cases in each State/UT
2. Show Recovery rate of each State/UT
3. Show Death rate of each State/UT
4. Search details of any State/UT
5. Modify details of any State/UT
6. Exit

Answers

Answered by savadinamrata
1

Answer:

so what we have to do in this question

Answered by jai696
1

\huge\red{\mid{\fbox{\tt{Using\: Python\: 3}}\mid}}

import sys

states = [

{

"id": 1,

"name": "Arunachal Pradesh",

"total_cases": 544971,

"recovery_rate": .83,

"mortality": .54

},

{

"id": 2,

"name": "Meghalaya",

"total_cases": 498305,

"recovery_rate": .14,

"mortality": .17

},

{

"id": 3,

"name": "Delhi",

"total_cases": 765106,

"recovery_rate": .53,

"mortality": .88

},

{

"id": 4,

"name": "Punjab",

"total_cases": 347713,

"recovery_rate": .17,

"mortality": .14

},

{

"id": 5,

"name": "Bihar",

"total_cases": 347713,

"recovery_rate": .33,

"mortality": .46

}

]

def total_cases():

for state in states:

print(state["name"], state["total_cases"])

def recovery_rate():

for state in states:

print(state["name"], str(state["recovery_rate"] * 100) + "%")

def mortality():

for state in states:

print(state["name"], str(state["mortality"] * 100) + "%")

def state_info():

for state in states:

print("id:", state["id"], "name:", state["name"])

print()

_id = int(input("enter id: "))

for state in states:

if _id == state["id"]:

for k, v in state.items():

print(f"{k}: {v}")

def state_modify():

for state in states:

print("id:", state["id"], "name:", state["name"])

print()

_id = int(input("enter id: "))

for state in states:

if _id == state["id"]:

print("choose id of option")

print("\n".join(["1 name", "2 total_cases", "3 recovery_rate",

"4 mortality"]))

print()

cmd = int(input("id: "))

if cmd == 1:

name = input("name: ")

if len(name) > 0:

state["name"] = name

print(state)

return

if cmd == 2:

total_cases = int(input("Total Cases: "))

if total_cases > -1:

state["total_cases"] = total_cases

print(state)

return

if cmd == 3:

recovery_rate = int(input("Recovery Rate: "))

if recovery_rate > -1:

state["recovery_rate"] = recovery_rate

print(state)

return

if cmd == 4:

mortality_rate = int(input("Mortality rate: "))

if mortality_rate > -1:

state["mortality_rate"] = mortality_rate

print(state)

return

def cmd_matcher(cmd):

if cmd == 1:

return total_cases()

if cmd == 2:

return recovery_rate()

if cmd == 3:

return mortality()

if cmd == 4:

return state_info()

if cmd == 5:

return state_modify()

print("exiting...")

return sys.exit()

while True:

print("\n".join(["1 Total Cases", "2 Recovery Rate", "3 Mortality Rate",

"4 State Info", "5 Update State Info", "6 Exit Program"]))

print()

cmd = int(input("Choose 1-6: "))

ids = [state["id"] for state in states]

if cmd not in ids and cmd != 6:

print("Choose between 1-6")

continue

else:

cmd_matcher(cmd)

break

\large\mathsf\color{lightgreen}useful?\: \color{white}\longrightarrow\: \color{orange}brainliest!

Similar questions