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

ex. 0.3.5 #23

Closed AkselSB closed 3 years ago

AkselSB commented 3 years ago

Hello

I'm confused about the notion of "calling" a function. Looking up tutorials I see it allows me to link(?) functions together, but I'm not sure how the 'exponentiate' and 'natural_logarithm' variables should be connected. The wording is confusing.

Thanks in advance

amaliemaria commented 3 years ago

I was also confused by this exercise.

Konstantin-Babayan commented 3 years ago

Hey Amalie and Ondskabsfyrsten

I was wondering about the same thing but figured out in the end how to solve the problem. The solution is actually very simple (as I understand). They want you to define an exponentiate function that can take any other functions as an input (the input variable in their example is called func). Hence, natural_logarithm is a function than can be used as an input in this case. In other words you should end up with exponentiate(natural_logarithm) which you equal to logexp. I hope it helps. Note, make sure to run the eulers_e in problem 0.3.3 and natural_logarithm in 0.3.4, otherwise the program would not be able to recognise these functions.

AkselSB commented 3 years ago

Hey Konstantin,

Thanks a ton! Unfortunately, the query is still giving me problems. I might not have understood the previous bit properly, which makes it difficult to see what is wrong for me. Hope you can help: image

Thank you in advance

joachimkrasmussen commented 3 years ago

Hi @Ondskabsfyrsten,

So there are basically two things that you need to do here:

  1. Specify what #[FILL IN] should be replace wiht. The answer is basically given to you in the question: _The nested function should return func(e, k) where e=eulers_e(x, k)_. As we can see in the code snippet, the nested function returns value, so therefore value should be equal to...?
  2. Next, exponentiate() takes a function as input. Now, in the question, we are essentially asking you to try and use natural_logarithm as this input. Try this out and store this object as logexp. What will now happen if you write logexp(1, 100)?

And thank you for the helpful comment, @Konstantin-Babayan.

Best, Joachim

joachimkrasmussen commented 3 years ago

Hi @Ondskabsfyrsten

Regarding your second comment: Try and switch exponentiate(natural_logarithm) and logexp on each side of =. Does this help?

Best, Joachim

AkselSB commented 3 years ago

Hi @joachimkrasmussen

I've switched around exponentiate(natural_logarithm) and logexp but I'm still confused regarding what has to be stored with value. : image

Thank you in advance

joachimkrasmussen commented 3 years ago

OK, there there seems to be two problems here:

  1. Again, you need to swich answer_035 and logexp(1,100). When you create a new object (here answer_035), you need to put that new object before =. Then after the equality sign, you specify the object (in this case as logexp(1,100).
  2. Your code does not know what function() is, as this has not been specified anywhere. However, it know what func() is, as this was the input in exponentiate. Can you use this information somehow?

Best, Joachim

AkselSB commented 3 years ago

I think I worked it out. Thank you for the patience!