I need some help

For students who are taking a programming course, may be restricted in what they can use, or have other unusual limitations on solving their task.

I need some help

Postby gamechick1988 » Tue Sep 13, 2016 12:51 pm

I've started to learn python on my own and I've came to a stop.
The exercise says that I need to find the value of the following expression :
Code: Select all
def foo(x, y = 5):
   def bar(x):
      return x + 1
   return bar(y * 2)
         
foo(3)


But I don't know what I need to do or how to start solving this. can someone help me?
Last edited by micseydel on Tue Sep 13, 2016 2:46 pm, edited 1 time in total.
Reason: Fixed code tags. Initial post lock.
gamechick1988
 
Posts: 2
Joined: Tue Sep 13, 2016 12:45 pm

Re: I need some help

Postby micseydel » Tue Sep 13, 2016 2:48 pm

Have you tried running the code? This can also be helpful, though I recommend you use it to correct misconceptions rather than as a basis for regular use.
Due to the reasons discussed here we will be moving to python-forum.io on October 1, 2016.

This forum will be locked down and no one will be able to post/edit/create threads, etc. here from thereafter. Please create an account at the new site to continue discussion.
User avatar
micseydel
 
Posts: 3000
Joined: Tue Feb 12, 2013 2:18 am
Location: Mountain View, CA

Re: I need some help

Postby Ofnuts » Tue Sep 13, 2016 2:56 pm

<voice type="Admiral Ackbar">It's a trap!</voice>

In other words, check very carefully what happens :)
This forum has been moved to http://python-forum.io/. See you there.
User avatar
Ofnuts
 
Posts: 2659
Joined: Thu May 14, 2015 9:46 am
Location: Paris, France, EU, Earth, Solar system, Milky Way, Local Cluster, Universe #32987440940987

Re: I need some help

Postby sparkz_alot » Tue Sep 13, 2016 3:29 pm

I would also suggest adding some strategically placed "print" statements in your code. As it stands, you will see no output ;)
THIS FORUM WILL BE CLOSING OCT 1, 2016. PLEASE STOP BY AND REGISTER AT THE NEW LOCATION
http://python-forum.io
User avatar
sparkz_alot
 
Posts: 269
Joined: Sat Dec 06, 2014 2:55 pm
Location: US

Re: I need some help

Postby gamechick1988 » Tue Sep 13, 2016 7:34 pm

Thanks micseydel. those visualisations are very useful :) now I finally understand how that process goes
gamechick1988
 
Posts: 2
Joined: Tue Sep 13, 2016 12:45 pm


Return to Homework

Who is online

Users browsing this forum: No registered users and 4 guests