TuringTest 3 years ago Python lessons for absolute beginners? I was using the MIT thing http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-189-a-gentle-introduction-to-programming-using-python-january-iap-2008/lecture-notes/exam1_soln.pdf but since I had never even done the "hello world" thing before it's a bit fast-paced for me. I'm also reading Sthurlow.com's tutorial, which seems too slow. Any good suggestions?

1. TuringTest

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)

2. arcticf0x
3. FoolForMath

If you ask me, Python as the first computer language is not advisable.

4. FoolForMath

Coming back to problem 10, f(a) is function which is returning a value.

5. TuringTest

@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.

6. FoolForMath

@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.

7. arcticf0x

@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.

8. sasogeek

@TuringTest start here :) http://openbookproject.net/thinkcs/python/english2e/

9. sasogeek

@FoolForMath C as the first language????? you've got to be kidding me!

10. nczempin

I'm curious, why do you think C makes a good first language and Python doesn't? This goes against all conventional wisdom.

11. nczempin

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.

12. FoolForMath

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.

13. nczempin

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?

14. nczempin

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.

15. sasogeek

"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

16. nczempin

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.

17. sasogeek

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.

18. nczempin

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)

19. TuringTest

@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.

20. nczempin
21. nczempin

22. nczempin

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.

23. nczempin

6.002, not 8.002

24. nczempin

What do you mean by "the videos in udacity have increased in difficulty sufficiently in my opinion,"; don't you mean "decreased in difficulty"?

25. TuringTest

no, the exercises have become more difficult

26. nczempin

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 :-)

27. nczempin

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 ;-)

28. TuringTest

thank you very much for your input @nczempin it seems I still have much to sort out

29. sasogeek

LOL, that won't be quite a challenge considering he's quite vested with the language...

30. nczempin

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.

31. sasogeek

well that makes sense :)

32. nczempin

@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.

33. FoolForMath

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.

34. nczempin

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?

35. s3a

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.