Open utterances-bot opened 3 years ago
I finished this exercise
An example of how to write code blocks
name = "Jose"
I thought that it is always the case that you had to define variables... However in this example you first write/use variables before they are defined.
Maybe you are confusing def
with variables def is to define functions.
If you look at this piece of code:
C = 1000000
I = 500000
G = 800000
X = 100000
M = 2000000
Y = C + I + G + (X - M)
Variables have been declared and values have been assigned.
The first code is more Explicit and more Simple than the second.
Some reasons why using a function is better:
get_gdp()
so it is more explicit about what the code does I did not get that line about the Dutch :)
The Zen of Python Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. Flat is better than nested. Sparse is better than dense. Readability counts. Special cases aren't special enough to break the rules. Although practicality beats purity. Errors should never pass silently. Unless explicitly silenced. In the face of ambiguity, refuse the temptation to guess. There should be one-- and preferably only one --obvious way to do it. Although that way may not be obvious at first unless you're Dutch. Now is better than never. Although never is often better than right now. If the implementation is hard to explain, it's a bad idea. If the implementation is easy to explain, it may be a good idea. Namespaces are one honking great idea -- let's do more of those!
I also didnt get the line about the dutch :) maybe the dutch can explain us :D
But I found that C = 1000000 I = 500000 G = 800000 X = 100000 M = 2000000 Y = C + I + G + (X - M) is also beautiful
the function makes it easier to replicate the process for more countries
We Dutch seem to allow only one interpretation or option, according to the non-Dutch;)
Variables, values, inputs, outputs — Python essentials for GIS learners
https://the-magnificents.github.io/04-02-2021-Carpentry-for-HGIS/01_Day_1_Unix_Shell/excercises/B2_Exercise.html