Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,150,742 members, 7,809,835 topics. Date: Friday, 26 April 2024 at 03:42 PM |
Nairaland Forum / Science/Technology / Programming / Please Help With This Python Code (2246 Views)
Check Out My Python Code For Giving You The Date/time You Are Currently. / I Need HELP With This Python Problem / Python Code For Birthday Reminder (2) (3) (4)
Please Help With This Python Code by cyrielo(m): 6:19pm On Apr 27, 2015 |
from math import sqrt def zscore(obs, pop): # Size of population. number = float(len(pop)) # Average population value. avg = sum(pop) / number # Standard deviation of population. std = sqrt(sum(((c - avg) ** 2) for c in pop) / number) # Zscore Calculation. return (obs - avg) / std Am not a python developer, am php but this code looks pretty self explanatory, the confusing part is the double ** what does this mean in python, I need to implement this function in php, thanks guys |
Re: Please Help With This Python Code by loomer: 6:22pm On Apr 27, 2015 |
Anaconda |
Re: Please Help With This Python Code by Nobody: 6:40pm On Apr 27, 2015 |
na cobra code i know. |
Re: Please Help With This Python Code by cyrielo(m): 6:43pm On Apr 27, 2015 |
when the function is called this is the output ==>>zscore(12, [2, 4, 4, 4, 5, 5, 7, 9] ) ==>>3.5 |
Re: Please Help With This Python Code by kurtisblue: 7:37pm On Apr 27, 2015 |
cyrielo: It means power of BTW y use float for population? |
Re: Please Help With This Python Code by Aybee92(m): 9:01pm On Apr 27, 2015 |
d double ** means power e.g 4**3 is same as 4^3 |
Re: Please Help With This Python Code by sisqology(m): 9:02pm On Apr 27, 2015 |
Raise to power |
Re: Please Help With This Python Code by cyrielo(m): 9:33pm On Apr 27, 2015 |
Thanks guys |
Re: Please Help With This Python Code by kudaisi(m): 1:55pm On Apr 28, 2015 |
Also bear in Mind that ** when being used with a function argument it will have entirely different meaning in variance to power function it performs in this example. So if you see a code like this def foo(arg1, ** arg2):The above does note mean arg1 raised to the power of arg2 |
Re: Please Help With This Python Code by sisqology(m): 6:06pm On Apr 28, 2015 |
kudaisi: def foo(*args, **kwargs): #some code |
Re: Please Help With This Python Code by kudaisi(m): 2:02am On Apr 29, 2015 |
sisqology:Did I miss something ? If you mean to refer to '*args, **kwargs' it just a common idiom used in such scenarios. It can be changed with any variable name you please as long as it does not interfere with the inbuilt Python keywords. |
Re: Please Help With This Python Code by sisqology(m): 9:03am On Apr 29, 2015 |
kudaisi: No bro, I was only talking about another aspect where u can see ** |
Re: Please Help With This Python Code by kudaisi(m): 9:43am On Apr 29, 2015 |
sisqology:Oh!..okay. Cool. |
Re: Please Help With This Python Code by babatope88(m): 11:29am On Apr 29, 2015 |
You can do something like this as of <?php //php >=5.6.0 $power = $num**$base is accepted //With old there is php built in power function pow($num, $base); |
Re: Please Help With This Python Code by spoilerx: 9:57am On May 01, 2015 |
cyrielo: you didn't define the variable c |
Re: Please Help With This Python Code by tr3y(m): 8:27pm On Apr 21, 2016 |
cyrielo: Your email has issues, anything I can help you with? |
Re: Please Help With This Python Code by cyrielo(m): 9:19pm On Apr 21, 2016 |
tr3y:Yeah, how did it go with andela. im in the same scenario as you |
Re: Please Help With This Python Code by tr3y(m): 12:01am On Apr 22, 2016 |
cyrielo:I went there for my interview and my name was actually on the list they had so I didn't bother to ask why they sent the regret mail |
Re: Please Help With This Python Code by cyrielo(m): 12:52am On Apr 22, 2016 |
tr3y:oh nice |
Re: Please Help With This Python Code by tr3y(m): 12:06pm On Apr 22, 2016 |
cyrielo: Did you get any interview message from U-CONNECT? |
Re: Please Help With This Python Code by cyrielo(m): 1:51pm On Apr 22, 2016 |
tr3y:what is U-CONNECT? |
(1) (Reply)
An Escrow Like System / Get 4GB For 1k On MTN. Valid For One Month / I Want To Become A Hacker And I Need A Good Source, Any Help?
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 20 |