Ace school

with brainly

  • Get help from millions of students
  • Learn from experts with step-by-step explanations
  • Level-up by helping others

A community for students.

Hello everyone Since last week I'm very upset with the problem set 1. the first program istead of doing the same thing from 1 month to 12 months How can I use loop to do it one time. What I want is an alogarithm for the first program. Thank you

MIT 6.00 Intro Computer Science (OCW)
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com 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.

Join Brainly to access

this expert answer

SIGN UP FOR FREE
but mean: p1*p2*p3*pn <= e**N == log(p1)+log(p2)+log(pn)< N result=result + math.log(primeNumber) ratio= result/N
I'm assuming, based on your question, that you are already good with computing the formulas and you just want to know how to write the code so you don't have to copy and paste it 11 times to make twelve copies of the calculation. the best way to get the information is to watch the lectures and recitation, I believe (section 4 of unit 1 ) is where loops are covered. However, if that's too much sifting through to do I'll give you a shortened explanation. There are two different loops. One is the While loop and the other is the For loop. The while loops is relatively self-explanatory; the block of code in the while loop will run WHILE a certain variable meets the condition (true, false, x=3...). A For loop runs a block of code a specific number of times. the syntax for a while loop in python is (hash-tags are comments): #declare a variable of any name. i is regularly used #and the variable is not limited to numbers somevariable = 0 #this while loop will run twelve times total while (somevariable <12): #indent instead of bracketing #the next line of code is there to give the loop some way to end. somevariable = somevariable + 1 #insert block of code (i.e. calculations and print) #remove indent to end while loop the syntax for a For loop is: #this loop will run twelve times total #the 0 is the starting place #the 12 is the limit #and the 1 is the amount added to the number each time it's repeated for i in range of (0,12,1): #indent #insert block of code (i.e. calculations and print) #remove indent to end while loop You should play around with these concepts to find a way that works for you in learning them. Finally here is some reading material that was given in section 3 that will help your understanding of loops. although I believe this refers to some syntax that can be used in a different version of python because the whole end=" " thing doesn't work in 2.5 (the classes version) http://beastie.cs.ua.edu/cs150/book/index_14.html I hope that answers your question.

Not the answer you are looking for?

Search for more explanations.

Ask your own question

Other answers:

Not the answer you are looking for?

Search for more explanations.

Ask your own question