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

lesson 1.4 Part 2 I'm having trouble with how to code the answer: 7+9=16 sqrt 4*2=8. any help is greatly appreciated

OpenStudy (anonymous):

is this part of python MOOC or something else?

OpenStudy (anonymous):

it's part of 6.189 Homework 1 Exercise 1.4 I hope I'm working on the right assignments

OpenStudy (anonymous):

yes, it's part of the MOOC... sorry.

OpenStudy (anonymous):

hm, I seem to have different numbers/task but if you question is python code to print those results then just simply use print: print 7+9 print 4*2

OpenStudy (anonymous):

Thanks @zlatandebian I might have printed off the wrong assignments

OpenStudy (anonymous):

No problem, and just in case you needed sqrt of 4 to get 16, then you just put two asterix as: print 4**2

OpenStudy (anonymous):

Your the best, Thanks! Now to figure out this raw_input stuff (exercise 1.5 User Input). being a noob programmer is tough -lol!

OpenStudy (anonymous):

hm, I am noob also ;) well I don't think we need to do 1.5 at first week. Anyway its fairly straightforward looking to me. Just assign some variables with raw_input and print it out. P.S. if you need to get 4 from 16 then just use negative number as: print 16**(-2). Cheers

OpenStudy (anonymous):

@ zlatandebian you've been a lifesaver. I did the following for 1.5 exercise e = raw_input ("Enter your first name?") f = raw_input ("Enter your last name?") g = raw_input ("Enter your date of birth") print e + + f + + g sadly this is what I'm getting: >>> ================================ RESTART ================================ >>> Enter your first name?john Enter your last name?doe Enter your date of birth1/1/1900 johndoe1/1/1900 >>>

OpenStudy (anonymous):

if you need it to be in one line you must have spaces between (and also there is no need to use two pluses, one is ok). so just add empty spaces ( hint: use " ") if you want to put it one below another then you need 3 print statements print e print f print g

OpenStudy (anonymous):

awesome! Thanks again!!

OpenStudy (anonymous):

do you know where/how we turn in our homework?

OpenStudy (anonymous):

I don't know about that really (I do not know if we even need to turn our homework :-/). Maybe @MOOC-E could tell us more?

OpenStudy (anonymous):

sounds good. I'll leave you alone now :) and wait for a response from @MOOC-E

OpenStudy (anonymous):

Just to share flexibility of python - while I looked at raw_input assignment I noticed that you could nice print one line as follow: print x, y, z Yay, Monty! :)

OpenStudy (anonymous):

Hey @nsite7, no you don't submit homework in this course. Mostly you can tell if it works or it doesn't in the Python interpreter. Feel free to post code on OpenStudy for feedback from your fellow learners.

OpenStudy (anonymous):

@ zlatandebian - Cool! @MOOC-E - Thanks, I'm really looking forward to learning Python and hopefully not having to bother everyone so much in the future.

OpenStudy (rsmith6559):

A couple of terminology corrections: 4 squared is programmed 4**2. The square root of 4 is programmed 4**.5 or import math math.sqrt( 4 ) FYI, raw_input() returns a string. If you want to use it for numbers: foo = float( raw_input( "Enter a number: " ) )

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!