- 1

How this piece of code works and why it is needed?

print('EXP() Function on Tuple Item = %.2f' %math.exp(67))

23rd Oct 2019, 6:13 PM
Thakur Lion😎😎
Thakur Lion😎😎 - avatar
5 odpowiedzi
+ 1
in what code? please upload your code here
23rd Oct 2019, 6:38 PM
Brave Tea
Brave Tea - avatar
+ 1
right :) first off you I think you have your lines and such mixed up, because line 29 isn’t the same as in your question plus I can’t find a line anywhere that has the combination of tuple and 67 (which btw would be weird if it existed because it doesnt refer to a tuple but to a integer namely 67) so here goes: -tuple: immutable set of unranked and unique numbers -if it says tup[2] it refers to the 3rd entry in the tuple (it is zero indexed) and that would be 13.05 - math.exp() this function exp() raises e (or Euler’s (which is about 2.71) number to the power of the given number so math.exp(13.05) (which is the same as math.exp(tup[2]) in our example) is going to be somewhere around 465096.something exp(2) == e^2 == ~2.71^2 == ~7.31 why would you use Euler? no clue, i am not a mathematician, but it has maths applications. this you can google -then the %.2f stuff this is string formatting (this is one of 3 ways to do it) writing this in your string and then putting the %math.exp(67) after the string
24th Oct 2019, 6:51 AM
Brave Tea
Brave Tea - avatar
+ 1
(ran out of room to type) does the following where % is in string put what comes after second % in string in that place. but! do this as a floating point (f) with 2 after the decimal point (.2) this should answer how the code works. - why it is needed? well it isnt needed in this code. this code is from a website that explains about the exp() function and this code is meant to explain it to you. honestly that is it. I didnt know what it did until i read it and looked up the website please in future, make sure you ask your question more specifically.I have answered every part of your very broad and vague question except for what print() does this is because I had time to kill and I learn through teaching. other people won’t respond so kindly, or won’t respond at all to broad and vague questions. hopefully this answers your question
24th Oct 2019, 6:56 AM
Brave Tea
Brave Tea - avatar
24th Oct 2019, 4:24 AM
Thakur Lion😎😎
Thakur Lion😎😎 - avatar
0
Line no.29
24th Oct 2019, 4:24 AM
Thakur Lion😎😎
Thakur Lion😎😎 - avatar