Ask your own question, for FREE!
MIT 6.189 A Gentle Introduction to Programming Using Python (OCW) 7 Online
OpenStudy (anonymous):

How do you make a function?

OpenStudy (anonymous):

Very basic example def f(x): return x (colon and indentation are important) Then call f(3) and it will return 3 This is in Week 2 I think.

OpenStudy (anonymous):

Oh, so x = 3? def means function, then a name, then a value, then code? Thanks, hope this works!

OpenStudy (anonymous):

look at one here: http://www.codeskulptor.org/

OpenStudy (konradzuse):

What language?

OpenStudy (anonymous):

this is Python study group...

OpenStudy (konradzuse):

Oh I keep missing the little MIT tags.

OpenStudy (anonymous):

np:-)

OpenStudy (konradzuse):

It's always Python and C >(.

OpenStudy (anonymous):

I love C! Well, C++ for Arduino. That's how I started...Anyway, I get it now. You input a variable, and it does something to it. def f(z): return z+1 Should return 4 if I typed f(3)? Am I right?

OpenStudy (anonymous):

Yup.

OpenStudy (anonymous):

Ok, thanks! Closing question...

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!