Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,150,742 members, 7,809,835 topics. Date: Friday, 26 April 2024 at 03:42 PM

Please Help With This Python Code - Programming - Nairaland

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)

(1) (Reply) (Go Down)

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:


the confusing part is the [b]double ** [/b]what does this mean in python, I need to implement this function in php, thanks guys



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 cool
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):
#some code here
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:
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):
#some code here
The above does note mean arg1 raised to the power of arg2


def foo(*args, **kwargs):
#some code





undecided
Re: Please Help With This Python Code by kudaisi(m): 2:02am On Apr 29, 2015
sisqology:
def foo(*args, **kwargs):
#some code
undecided
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:
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.


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:

No bro, I was only talking about another aspect where u can see **
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:
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


you didn't define the variable c
Re: Please Help With This Python Code by tr3y(m): 8:27pm On Apr 21, 2016
cyrielo:

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

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:

Your email has issues, anything I can help you with?
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:

Yeah, how did it go with andela. im in the same scenario as you
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:

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
oh nice
Re: Please Help With This Python Code by tr3y(m): 12:06pm On Apr 22, 2016
cyrielo:
oh nice

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:


Did you get any interview message from U-CONNECT?
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
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.