A community for students.

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

anonymous

  • one year ago

Consider the following algorithm. for i is in {1, 2, 3, 4} do beep for j is in {1, 2, 3, 4} do beep for k is in {1, 2, 3} do for l is in {1, 2, 3, 4, 5, 6} do beep for m is in {1, 2, 3, 4, 5} do beep How many times does a beep statement get executed?

  • This Question is Closed
  1. IrishBoy123
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 1

    check the indents which are absolutely crucial but indexed like this in Python ==> **152** times x = 0 for i in range(1,5): x+=1 for j in range(1,5): x+=1 for k in range(1,4): for l in range(1,7): x+=1 for m in range(1,6): x+=1 print x NB "range" doesn't run on the last item in Python so range(1,5) \(\equiv\) {1,2,3,4} assuming that is how your source works

  2. anonymous
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Thank you! I tried calculating, but did not get it. So, I have to add 1 to every range? and then add them all together and multiply by 4? is that how you got the final answer?

  3. IrishBoy123
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 1

    no i just re-wrote the instructions in Python and ran it you could work it out by hand, of course you could.

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

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.