isdsucph / isds2021

Introduction to Social Data Science 2021 - a summer school course https://isdsucph.github.io/isds2021/
MIT License
22 stars 37 forks source link

Problem 0.3.2 #5

Closed Casper17-max closed 3 years ago

Casper17-max commented 3 years ago

image

Jeg forstår ikke hvad problemet er i 'in [21]:'

joachimkrasmussen commented 3 years ago

Hi Casper,

It seems that you are simply printing a function. Note that your function is taking a argument y. Try and print your function while also specifying the argument (like: print(my_fun(y))).

Best, Joachim

Casper17-max commented 3 years ago

Thank you, that helped :-)

johankll commented 3 years ago

Hi Joachim,

I have played a bit around with defining variables with and without 'print'. I seem to come to the conclusion that the print-function simply returns 'None'. Hence, the above code simply defines answer_032a=answer_032b=None.

Is my observation correct, or am I missing something? (the below picture illustrates what i have "found") image

joachimkrasmussen commented 3 years ago

Hi Johan

My experience is that you should generally not define any variables the following way: y = print(2*x)

Always do the following:

y = 2*x
print(y)

That is, don't generally create a new object from print(). In general, only use print() when you have a personal desire to understand what is going on with your code. Does that make sense?

Best, Joachim

johankll commented 3 years ago

Hi Joachim,

Thanks for the answer.

It makes perfect sense. It is exactly what i thought.

/Johan