• anonymous
In exercise 1.8 how do you convert a fraction into a decimal using a for loop? I was somewhat able to do it by getting the indexes without using a loop, but there has to be a better way!
MIT 6.189 A Gentle Introduction to Programming Using Python (OCW)
  • schrodinger
I got my questions answered at in under 10 minutes. Go to now for free help!
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.

Get this expert

answer on brainly


Get your free account and access expert answers to this
and thousands of other questions

  • anonymous
Step 1. Go to the MIT OCW course page for 6.189 here: Step 2. Go into the PDF for Written Excercises Step 3. Write a loop to count from 2 to 10 for the number on the bottom of the fraction for n in range (2,11): Step 4: In the body of the loop, print the fraction in decimal form print 1.0/n That should do it. To make it more explicit what is happening, it could be coded like this too: print 1.0/float(n) To actually do the division doesn't require us to write a for loop, fortunately, since python knows how to do that without our involvement!
  • anonymous
Thank you so much!!!!! I really appreciate it!!

Looking for something else?

Not the answer you are looking for? Search for more explanations.