worldbank / dec-python-course

14 stars 5 forks source link

Session 2 Feedback Winter 2023 #41

Closed kbjarkefur closed 9 months ago

kbjarkefur commented 1 year ago

We assume that participants should have some knowledge of programming so topics like loops and if-statements, but maybe it is good to mention that we assume this, but then still spend 30 sec in beginning of each of those topics on why we want to use loops and if-statements. I think it creates a better flow.

kbjarkefur commented 1 year ago

Potentially use f-strings instead of string concatenation in the example below and the examples in the cell after this one.

for country in gdp_dict.keys():
    print(country + "'s GDP in 2020 was "+ str(gdp_dict[country]) + " billion US dollars.")

I think this is a better practice to teach and it looks cleaner and therefore easier to follow.

kbjarkefur commented 1 year ago
requests.get(f"https://api.worldbank.org/v2/sources/2/country/{country}/series/{series}/time/{'yr'+str(time)}?format=json").json()

can be simplified to

requests.get(f"https://api.worldbank.org/v2/sources/2/country/{country}/series/{series}/time/yr{time}?format=json").json()

f-strings convert variables to its string representation, and the string representation of the int 2020 is '2020'

gauravcusp commented 9 months ago

We assume that participants should have some knowledge of programming so topics like loops and if-statements, but maybe it is good to mention that we assume this, but then still spend 30 sec in beginning of each of those topics on why we want to use loops and if-statements. I think it creates a better flow.

I think we do have a problem statement that says we want to avoid repetition and make the code compact. But I'll be sure cover the cover that in the session

gauravcusp commented 9 months ago

Potentially use f-strings instead of string concatenation in the example below and the examples in the cell after this one.

for country in gdp_dict.keys():
    print(country + "'s GDP in 2020 was "+ str(gdp_dict[country]) + " billion US dollars.")

I think this is a better practice to teach and it looks cleaner and therefore easier to follow.

Added this is one of the cells.