Got Homework?
Connect with other students for help. It's a free community.
Here's the question you clicked on:
 0 viewing
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
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

rsmith6559Best ResponseYou've already chosen the best response.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

breetBest ResponseYou've already chosen the best response.0
Also, there will always be a solution as root^1 will equal input number when root equals number.
 one year ago

suirsussBest ResponseYou've already chosen the best response.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

harsimran_hs4Best ResponseYou've already chosen the best response.0
this will also print 'No pair of numbers relate exponentially to the given input" many times
 one year ago

RCMoreaBest ResponseYou've already chosen the best response.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
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
 Engagement 19 Mad Hatter
 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.