Quantcast

Got Homework?

Connect with other students for help. It's a free community.

  • across
    MIT Grad Student
    Online now
  • laura*
    Helped 1,000 students
    Online now
  • Hero
    College Math Guru
    Online now

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

memand Group Title

course# 6.00 Assignment# 1 Hi guys, do any of you have an idea for what I can use instead of zip in this piece of code http://dpaste.com/778395/ ??

  • 2 years ago
  • 2 years ago

  • This Question is Open
  1. lopus Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    your code es hard to reading. in my opinion this code is more readeble una funcion me facilita trabajar con codigo muy extenso. se puede reutilizar y a mi parecer de eso se trata todo el punto 1 http://dpaste.com/778396/

    • 2 years ago
  2. choutos Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    I am quite lost, what is the purpose of the script?

    • 2 years ago
  3. bwCA Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    use two loops, one inside the other http://dpaste.com/779923/

    • 2 years ago
  4. memand Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    That is a really good idea, now I just have the problem that it hits an infinite loop at append.primes(n) where it appends n an infinite amount of times until it hits 1000 in primes_found... Can you see why it does that? Because I don't get why. http://dpaste.com/781781/

    • 2 years ago
  5. bwCA Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    this might be closer to what you wanted http://dpaste.com/781844/

    • 2 years ago
  6. memand Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    That actually seems to be exactly what I wanted :D But just for the sake of me understanding it better I hope you don't mid me asking: 1: What does the and p == primes += 1 part do for the process exactly? and 2: why did my code not work? And what I mean by that is, that by my logic it should be working and looping properly (witch was clearly not the case for the looping part) so I think I wasn't communicating properly to the interpreter what I wanted it to do, but I don't really see why it did not loop as I wanted. It can then be discussed that your version was more effective putting check_int += 1 in the start of the loop instead of in all the conditionals and stuff like that, but my question is still about the looping. Thanks a lot :D

    • 2 years ago
  7. bwCA Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    i didn't actually try your code - the first thing i saw is that the loop at line nine uses check_int_list but check_int_list never gets updated - you would be usinf the same number over and over. then, it looks like the loops at lines 8 and 9 are reversed - you want to test your number against all the primes in the list - for each number you want to check you want to run thru the list of primes. it helps to write down in words a sort of pseudocode explaining what you are trying to do - then turn it into code - it is easier than just trying to write the code off the top of your head. print statements are a good way to debug your code - it lets you see what is actually happening so you can compare to what you intended - here is your code with print statements - http://dpaste.com/782220/ I added p == primes[-1] because you cannot say a number is prime till you have tested it with all the previous primes. [-1] is a slice that points to the last item in a list - i think the tutorial in the Python docs covers slices. += is an operator that adds the number on the right to the number on the left. a+=1 is equivalent to a = a+1. This operator is listed in the Python documentation which should be installed on your computer (F1 from within Idle).

    • 2 years ago
    • Attachments:

See more questions >>>

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.