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

suirsuss

book question is : write a program that asks the user to enter an integer and prints two integers, root and pwr, such that 0 < pwr < 6 and root**pwr is equal to the integer entered by the user. if no such pairing exists state a message to that effect. so far i have : number = int(raw_input('Enter an integer: ')) root=0 pwr=0 while root**pwr <= number and pwr<6: pwr +=1 ##need to check if different roots will work before increasing pwr again## if root**pwr = number: print root,',',power else: print 'No pair of numbers relate exponentially to the given input"

  • one year ago
  • one year ago

  • This Question is Closed
  1. rsmith6559
    Best Response
    You've already chosen the best response.
    Medals 0

    I've never seen the double pound sign after a comment. AFAIK, a single pound sign before the comment, tells the interpreter that the rest of the line is a comment. The if statement on the following line is probably not what you want. A single '=' is assignment. Comparison is "==". root is never changed from 0. I would guess that you want to have a nested ( one inside the other ) loop for this.

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

    Also, there will always be a solution as root^1 will equal input number when root equals number.

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

    good point breet .. but how disappointing a program it would be if it just returned the number you put in and power of one XD

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

    this will also print 'No pair of numbers relate exponentially to the given input" many times

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

    I'm not sure if you are still looking for this or not. I learned a lesson here: look at the book example! I really only looked at the examples to see the loop structures, mostly ignoring the content. When I got to the exercise, I spent a LOT of time trying to decide whether to use integers, how to handle remainders, or whether to use floats and how to convert back to integers at the end, etc. Finally I found an easier way. Then I realized my easier way is the way the author showed in his example! I won't be getting those hours of my life back. LOL! Anyway, here is how I did it if you still care. P.S. I updated this slightly because the old code was ugly. I'm not totally satisfied with this, but it is better: http://pastebin.com/DHPMnmJ5

    • one year 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.