At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
I feel so stupid, I still don't quite grasp example problem 10 on the MIT link the "return a" part confuses me (I'm sure this is painfully remedial, but I've been going caveman style for quite a while now)
Try this http://www.udacity.com/overview/Course/cs101/CourseRev/apr2012
If you ask me, Python as the first computer language is not advisable.
Coming back to problem 10, f(a) is function which is returning a value.
@FoolForMath and where would you advise me to start? btw I can figure out the math ideas like that (I think you know that I am already familiar with the concept of a function), but I am not sure why the program terminates at 5 is it that the output of b=0 is put in as a, and then then function does its job adding a 5, and that signals the end of the program? why? if f(a) acts as a+5 and "returns" a, that sounds to me like a recursive function that should go on forever, producing an AP with common dif 5 I don't really see how b comes into play... @arcticf0x thanks, I'm watching it but it is also a little slow-going.
@TuringTest: I would suggest learning C first. Back to the question: def f(a): a = a + 5 return a Here, f(a) is a function and a is the parameter. When we do: b=0 f(b) it means that we are calling function f as f(0) ; But note this is call by value so only only a copy of the variable is passed to the function and (not the address) so even afterwards when we are trying to access the value of b it is still 0; Now, if we do: b=f(b) Here, we are are again passing f(b) i.e f(0) to the function but in this case we are saving the return value. Thus b becomes 5; so afterwards whenever you are trying to access the value of b it will be 5. So if (again) you do: b=f(b) now b will be 10 (We are now passing f(b) i.e f(5)) Now recursive function is a function where the function call itself. For example: f(a): a = a+5; return f(a) this is a infinite recursion.
@TuringTest If you want it fast and would like to keep it simple, this http://www.codecademy.com/ is the best option. Plus, don't confuse yourself following more than one of these sites (sources, languages) at the same time, settle down with any language you like and the learning material, follow it fully.
@TuringTest start here :) http://openbookproject.net/thinkcs/python/english2e/
@FoolForMath C as the first language????? you've got to be kidding me!
I'm curious, why do you think C makes a good first language and Python doesn't? This goes against all conventional wisdom.
A good example why one shouldn't learn (and especially teach) C as a first language is all those people who come here with C (or C++!) questions, who have obviously not grasped the very basics of programming. If Python seems difficult, C will be an order of magnitude more difficult. I strongly second the Udacity course. My 12-year old son has just finished unit 1 (which consists of 40 parts); it is more interactive than the ocw course, with very frequent quizzes, and _especially_ the opportunity to type in code right there in the browser.
Apart from GW-BASIC and LOGO which I learned (and forgot) during grade schools, C is my first language! I find it interesting and enriching. But most of coding I (used to) do are algorithmic and as a part of programming contest training. Python is not yet accepted as official contest language so I wasn't much interested at that time. I learned python last year. Its beauty is in short and simple manipulations, it's a very good language when you are trying implement number theory algorithm. It has inbuilt bignum so you won't have to worry about integer overflows. Python offers a variety of math functions much more than C,C++ or Java. It also has inbuilt Lambda Calculus utility which is one of my favorite. To be honest, I don't know how could anybody think that C is harder than python?! In my opinion after say 6 months of C training one can easily understand almost any program written in C (using standard libraries) where as python has much more depths and variations. If anybody is interested, I started learning python form this book http://www.diveintopython.net/. It's free and of reasonable size, but that book might be somewhat difficult to comprehend for a beginner, so I would like to suggest http://www.swaroopch.org/notes/Python. This is undoubtedly the best book I have encountered so far.
How long have you been programming in C and in Python, and what other languages do you know? What's the biggest program you've written?
BTW, a good indication of the kinds of problems have that people who are learning how to program can be found right here in OpenStudy. There are many who are using C or even C++, and you can see the results. If someone who has learned C has trouble learning Python, that may also be because by learning C he has learned many specifics of the language, but is missing some general concepts of how to program. The best approach if you _really_ want to learn to think like an expert programmer is the SICP book (supplemented by its ocw course). There is a huge difference between "understanding almost any program written in C" (a claim with which I beg to differ) and _writing_ non-trivial C programs successfully and efficiently. I wouldn't know where to start with the complexity of C that will baffle a beginner, but string manipulation, collection data types and pointers are examples that immediately spring to mind.
"a good indication of the kinds of problems have that people who are learning how to program can be found right here in OpenStudy" I'm not exactly sure I understand what that means... i know it's probably the wording of the statement but if you could please explain cos i'm not making anything out of it :s
By that I mean that there seem to be a large percentage of people asking questions who are taking C or C++ courses who haven't grasped the most fundamental ideas, because they are fighting with the language more than with the methods of turning an idea (or set of requirements) into code.
true* Personally, C or C++ should be considered even maybe a 3rd or 4th language to learn. 1st language is out of the question. that's like a total disaster if one really wants to understand the concepts of programming.
And while it is not a good reason by itself, the suitability of Python as a first language is increasingly demonstrated by the adoption of it in entry-level courses at universities around the world (a change from other languages such as Scheme, which is possibly even more useful as a teaching language, but usually isn't used much outside of teaching; C never really was in the picture in that role)
@FoolForMath thank you for the explanation of the procedure if the specific function, I think I understand the concept a bit better @arcticf0x the videos in udacity have increased in difficulty sufficiently in my opinion, and seem to be helping me, so that is what I've been using. In OCW Python was suggested as a starting point for programming as part of the comp sci prerequisite for their circuits course in MITx, so I took that as sufficient reason to accept Python as a decent starting point, so long as I focus on concepts rather than syntax.
(from that link): "Appendix: Language Choice Several people have asked what programming language they should learn first. There is no one answer, but consider these points: Use your friends. When asked "what operating system should I use, Windows, Unix, or Mac?", my answer is usually: "use whatever your friends use." The advantage you get from learning from your friends will offset any intrinsic difference between OS, or between programming languages. Also consider your future friends: the community of programmers that you will be a part of if you continue. Does your chosen language have a large growing community or a small dying one? Are there books, web sites, and online forums to get answers from? Do you like the people in those forums? Keep it simple. Programming languages such as C++ and Java are designed for professional development by large teams of experienced programmers who are concerned about the run-time efficiency of their code. As a result, these languages have complicated parts designed for these circumstances. You're concerned with learning to program. You don't need that complication. You want a language that was designed to be easy to learn and remember by a single new programmer. Play. Which way would you rather learn to play the piano: the normal, interactive way, in which you hear each note as soon as you hit a key, or "batch" mode, in which you only hear the notes after you finish a whole song? Clearly, interactive mode makes learning easier for the piano, and also for programming. Insist on a language with an interactive mode and use it. Given these criteria, my recommendations for a first programming language would be Python or Scheme. But your circumstances may vary, and there are other good choices. If your age is a single-digit, you might prefer Alice or Squeak (older learners might also enjoy these). The important thing is that you choose and get started. "
I don't think you need any programming to do the 8.002 MITx course. The physics course (Electricity and Magnetism) and Differential Equations (which in turn require basic Calculus) are more useful to spend time with if 6.002 is your main goal and you don't already have the knowledge down pat.
6.002, not 8.002
What do you mean by "the videos in udacity have increased in difficulty sufficiently in my opinion,"; don't you mean "decreased in difficulty"?
no, the exercises have become more difficult
infrastructure is also a concern. Most people will be using Windows (I do recommend getting comfortable with Linux, e. g. Ubuntu, and install it for dual-boot, to anyone who wants to get serious with programming), and just getting "hello world" out the door requires at least Visual Studio Express Edition, which totally overwhelms you (even me, but I know what to ignore :-) with options. Python makes it much easier because there is interactive mode, and on the Udacity course you can just do the quizzes in the browser (but I am repeating myself :-)
I dare FoolForMath to write a program in C with the same functionality as what you're working on in the Udacity course in the same time that the course participants write it :-) Okay, I'll shut up now ;-)
thank you very much for your input @nczempin it seems I still have much to sort out
LOL, that won't be quite a challenge considering he's quite vested with the language...
Ok, I guess what I meant that _I_ wouldn't be able to finish a bug-free version in C in less time than a bug-free Python version even though I know C much better than I do Python.
well that makes sense :)
@TuringTest I certainly don't want to discourage anyone from learning how to program, but my guess is you'll have your hands full with 6.002. I know I would. Given that, it's an excellent course, comparable to the SICP course in termns of "really learn the important concepts well". But who am I to judge that, I know far more about programming than I do about electronics.
EDIT: (Removing personal information) @nczempin: 6 years as of now, I am fairly confident about my C and C++ language skill and moderately at python. Apart from ICPC training at my college I have practiced enormously at websites like topcoder,spoj, codechef and codeforces which gave me enough opportunity to write lots of non-trivial programs successfully in C, C++ and python.
No, I meant large programs, such as those that take a man-year or more to write. What's the biggest one you had a significant role on? Are you a professional programmer or a student?
Free concise ebook: http://www.swaroopch.org/notes/Python I recommend learning version 3. Edit: It seems this book has already been suggested. It's a concise read so if you're like me, you'll like this.