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

Who wants to check my first code for MechanicalMooc Week 1. http://pastebin.com/L6HvPADN Feel free to post a link to your own code too, so we can compare.

OpenStudy (espex):

One thing I would point out as a caution, this will only work when the root is a multiple of 2. w = math.sqrt (s) c = math.sqrt (w) print "so the 4th Root of " +str (s) + " is " + str (c)

OpenStudy (espex):

Something else you should be aware of is the answers you get in this section of code: print "********* Part III *************" print blank result1 = 2 + 3 / 4 * 5 print "2 + 3 / 4 * 5 = " + str (result1) result2 = (2 + 3 ) / 4 * 5 print "(2 + 3 ) / 4 * 5 = " +str (result2) Notice that the answer you get for the first equation is '2' and '5', now change the equations to this and look at the answer: print "********* Part III *************" print blank result1 = 2 + 3 / 4. * 5 print "2 + 3 / 4 * 5 = " + str (result1) result2 = (2 + 3 ) / 4. * 5 print "(2 + 3 ) / 4 * 5 = " +str (result2)

OpenStudy (anonymous):

1. Yeah i know that it's coded for that example given and wont work for even numbers. My point of view being that its what was asked. Almost like saying "I have been asked to do x but I'm going to do do x, y and z". If it was something that needed user input then i would have to code it different. 2. It does indeed change the result. Pretty much the same as above if you know what I mean. But yeah, I'm sure that for future assignments it will need to be more "idiot proof", to make sure that the code still works, yet for now I believe it suffices. I won't get any great comments or remarks from the university professor (baring yourself of course :) ) but it should and does pass. Does it not?

OpenStudy (espex):

The code looks good, just wanted to make sure you were aware of how it was behaving. :)

OpenStudy (anonymous):

Oh yeah. And as always your opinions are valued. I would hazard a guess that you are a Mathematics Professor who can code, would I be right?

OpenStudy (espex):

:) no, but you are not the first person to guess that. I am just a lowly electrician who is studying to be an electrical engineer and also likes computers.

OpenStudy (anonymous):

You also must have very good comprehension skills... Took me a minute to figure out jtb's answers! Ha. My answer's are in a much more "to the point" form. http://pastebin.com/0Qh2KNp0

OpenStudy (anonymous):

And again, certainly not knocking your code jtb - just saying it took me a second to figure out what you were doing! Ha.

OpenStudy (espex):

@Neec0 the first thing I see is the way your fraction is evaluated. Look at this part here and tell me what you expected to get: print 3*5/2+3

OpenStudy (anonymous):

Well. It should be (3*5)/(2+3).

OpenStudy (espex):

Right, but it is not. Also, print 4*(sqrt(-19 + 100))

OpenStudy (anonymous):

There needs to be an edit button, so that I can edit a single comment instead of adding a new one! Thanks for pointing that out! I did this assignment after the first lesson of both CS101 and College Algebra on Udacity. It was a long night, after a full day of work (where I am now. Ha).

OpenStudy (anonymous):

We talked about that one earlier! I must not have uploaded the correct program... Hold on...

OpenStudy (anonymous):

It should be something like this right? (sqrt(-19 + 100)**1/4)

OpenStudy (espex):

You can take the root portion out and leave it as a fraction exponent: (-19+100)**(1.0/4)

OpenStudy (anonymous):

Aye.

OpenStudy (anonymous):

Neec0 - Not a problem. I think it stems from always reading that I need to comment a lot or where it's meaningful. Hopefully i'll get the hang of it. Your code certainly looks cleaner. And it looks like I got Exercise 1.4 part 3 question 1 wrong. :(

OpenStudy (espex):

How so, there is only one question, which aside from the division, seems to work fine.

OpenStudy (espex):

Or are you talking about your order of operations explanation?

OpenStudy (anonymous):

The fraction. I've got my result as \[\frac{ 15 }{ 5 }\] displayed as 15/5 where as Moocs answer is 10.0. One of us is wrong and I'm definitely putting money on it being me.

OpenStudy (anonymous):

And I've just seen your post about to Neec0 about it and he's right about needing an edit button lol.

OpenStudy (espex):

Oh, question 1 of part II, I was looking at part III q1. :)

OpenStudy (espex):

Where is MOOCs answer?

OpenStudy (anonymous):

Couldn't point it out now as im logged of. But his answer is 10.0 as he didnt parenthesize his equation .

OpenStudy (espex):

Well, assuming we are still talking about \(\frac{3*5}{2+3}\) the answer is actually 3. However \(\frac{15}{5}\) is an acceptable answer and so yours is correct.

OpenStudy (anonymous):

Well one thing I definitely have learned from this is that I need to read and understand the code someone has written before I comment on it.

OpenStudy (anonymous):

Mine is here: https://github.com/gregsmyth/MOOC_homework_wk1/blob/master/hw1.py

OpenStudy (espex):

Nicely done @gregsmyth.

OpenStudy (anonymous):

Thanks. I'm new to Github (and Python) so am also pleased the link worked!

OpenStudy (espex):

The only suggestion I would offer is on your tic-tac-toe board, notice how the lines aren't perfectly centered, working on the format a bit will help that.

OpenStudy (espex):

For what it's worth, my solution for tic-tac-toe was as follows: top = ("__|__|__") bot = (" | |") print (top + "\n" + top + "\n" + bot)

OpenStudy (anonymous):

Is it just us? Or am I missing a whole other section where the MechMOOCrs are chatting away with questions and problem solving? :-)

OpenStudy (espex):

There appears to be a collection of forums associated with MOOC, OS being just one of them.

OpenStudy (anonymous):

? Did I miss something? Or do you mean github and the likes forums...

OpenStudy (espex):

It seems that there are forums on codeacademy, P2P University, and here. I had not heard of github until greg showed up.

OpenStudy (anonymous):

This is the only place the Mech MOOC points people to, but it would be cool to pull together a list of other forums where discussions related to the course are going on.

OpenStudy (anonymous):

I only upload code to Github. I think @MOOC-E suggested trying it out in one of the early emails. I come here for course related chat.

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!