DEV Community

Cover image for Coronavirus Tracker in Python? Get current COVID-19 Cases
Arpit
Arpit

Posted on

1 3

Coronavirus Tracker in Python? Get current COVID-19 Cases

# Author: codesnail

from covid import Covid
import matplotlib.pyplot as pyplot

covid = Covid()
print("Want data of specific country (press: 1)")
print("World data (press: 2)")
ch = int(input("Enter your choice: "))

if ch == 1:
    country = input("Enter your country name: ")
    data = covid.get_status_by_country_name(country)
    cadr = {
        key: data[key]
        for key in data.keys() & {"confirmed", "active", "deaths", "recovered"}
    }

    n = list(cadr.keys())
    v = list(cadr.values())
elif ch == 2:
    cadr = {
        "confirmed": covid.get_total_confirmed_cases(),
        "active": covid.get_total_active_cases(),
        "deaths": covid.get_total_deaths(),
        "recovered": covid.get_total_recovered(),
    }

    v = list(cadr.values())
    n = list(cadr.keys())

print(cadr) # print data


pyplot.title("Corona Tracker")
pyplot.bar(range(len(cadr)), v, tick_label=n)
pyplot.show()
Enter fullscreen mode Exit fullscreen mode

Explanation: codesnail

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (1)

Collapse
 
muhimen123 profile image
Muhimen

Nice beginners project. Using pyInquirer will surely make the CLI activities better.