10 Replies - 425 Views - Last Post: 27 September 2011 - 07:38 PM Rate Topic: -----

#1 sitdownson  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 16
  • Joined: 27-September 11

Basic python help question, beginner

Posted 27 September 2011 - 06:46 PM

Hey guys need help with this question for my intro class to python. Can't really figure it out to be honest, kind of lost.

Question: http://imageshack.us...8/unledvsk.png/

Here is what I have so far, not really right I don't think and I am far off.

value = int(raw_input("Enter an integer greater than 2: "))

def power():
    powerOfTwo = value ** 2
    powerOfThree = value ** 3
    powerOfFour = value ** 4

    print value, powerOfTwo , powerOfThree , powerOfFour 


Is This A Good Question/Topic? 0
  • +

Replies To: Basic python help question, beginner

#2 Simown  Icon User is offline

  • Blue Sprat
  • member icon

Reputation: 317
  • View blog
  • Posts: 650
  • Joined: 20-May 10

Re: Basic python help question, beginner

Posted 27 September 2011 - 06:54 PM

Take the the first question apart to start with, you will see you haven't done all of it:

"Uses a while loop to print the numbers from 2 to value inclusive" - you don't have a while loop.

"The function should display something similar to the following table" - your output won't look like the table.

Is the problem you don't understand how to do these? I'll try and help, I can't give you the answer, especially as it's homework.
Was This Post Helpful? 0
  • +
  • -

#3 airmalley  Icon User is offline

  • New D.I.C Head

Reputation: -2
  • View blog
  • Posts: 1
  • Joined: 27-September 11

Re: Basic python help question, beginner

Posted 27 September 2011 - 06:55 PM

ill pm you

This post has been edited by airmalley: 27 September 2011 - 06:55 PM

Was This Post Helpful? -2
  • +
  • -

#4 sitdownson  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 16
  • Joined: 27-September 11

Re: Basic python help question, beginner

Posted 27 September 2011 - 06:57 PM

View PostSimown, on 27 September 2011 - 06:54 PM, said:

Take the the first question apart to start with, you will see you haven't done all of it:

"Uses a while loop to print the numbers from 2 to value inclusive" - you don't have a while loop.

"The function should display something similar to the following table" - your output won't look like the table.

Is the problem you don't understand how to do these? I'll try and help, I can't give you the answer, especially as it's homework.


Thanks for the reply. The problem is to be honest is I just don't know how to go about this. I have no clue as to how to make it appear as a table and I am still iffy on while loops. Thanks
Was This Post Helpful? 0
  • +
  • -

#5 Simown  Icon User is offline

  • Blue Sprat
  • member icon

Reputation: 317
  • View blog
  • Posts: 650
  • Joined: 20-May 10

Re: Basic python help question, beginner

Posted 27 September 2011 - 07:00 PM

Ok, I'll give you some questions relating to this, see if you can answer them.

First, what is the syntax (how to do you write) a while loop?

If the while loop starts at with number=0, and won't stop until number=10, what do you have to do to number in the while loop?

View Postairmalley, on 28 September 2011 - 01:55 AM, said:

ill pm you


PMing someone is not the point of these forums, they are a community resource as well as personal help. If you have some input, please post it here.
Was This Post Helpful? 0
  • +
  • -

#6 airmalley  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 27-September 11

Re: Basic python help question, beginner

Posted 27 September 2011 - 07:06 PM

err i didnt mean for that to sound like i was helping him, i was saying that he is my friend and I was contacting him, sorryr

This post has been edited by airmalley: 27 September 2011 - 07:09 PM

Was This Post Helpful? 0
  • +
  • -

#7 Simown  Icon User is offline

  • Blue Sprat
  • member icon

Reputation: 317
  • View blog
  • Posts: 650
  • Joined: 20-May 10

Re: Basic python help question, beginner

Posted 27 September 2011 - 07:08 PM

Are you the same user on different accounts? I asked the user who originally posted the question, are you doing the assignment too?
Was This Post Helpful? 0
  • +
  • -

#8 airmalley  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 27-September 11

Re: Basic python help question, beginner

Posted 27 September 2011 - 07:10 PM

yeah sorry we are roomates, which is why i posted here earlier, shoudlve clarified =/

This post has been edited by airmalley: 27 September 2011 - 07:10 PM

Was This Post Helpful? 0
  • +
  • -

#9 Simown  Icon User is offline

  • Blue Sprat
  • member icon

Reputation: 317
  • View blog
  • Posts: 650
  • Joined: 20-May 10

Re: Basic python help question, beginner

Posted 27 September 2011 - 07:14 PM

That's certainly confused me, anyway. :)

The second question I was asking, I want to get from number = 0 to number = 10 using a while loop, finish this by adding increments of 2 the number and fill in the question marks:

number = 0
while number != ?
    number = ?


Was This Post Helpful? 0
  • +
  • -

#10 sitdownson  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 16
  • Joined: 27-September 11

Re: Basic python help question, beginner

Posted 27 September 2011 - 07:29 PM

View PostSimown, on 27 September 2011 - 07:14 PM, said:

That's certainly confused me, anyway. :)

The second question I was asking, I want to get from number = 0 to number = 10 using a while loop, finish this by adding increments of 2 the number and fill in the question marks:

number = 0
while number != ?
    number = ?



number = 0
while number != 10
    number += 2




I'm going to be completely honest. My main problem is the incrementing. I know how to do while loops when I actually enter data but i have no clue how to make it go from 0 to ten. Sorry for the delayed responses I am really struggling right now lol for some reason

This post has been edited by sitdownson: 27 September 2011 - 07:29 PM

Was This Post Helpful? 0
  • +
  • -

#11 Simown  Icon User is offline

  • Blue Sprat
  • member icon

Reputation: 317
  • View blog
  • Posts: 650
  • Joined: 20-May 10

Re: Basic python help question, beginner

Posted 27 September 2011 - 07:38 PM

Ok, now I enter a number:

value = int(raw_input("Enter an integer greater than 2: "))


How would I go from 2 to value now in 2s? Just the same as 0 to 10 really:

value = int(raw_input("Enter an integer greater than 2: "))
current = 2
while ? != ?:
    value = ?



I think you might not have realised you need two varibles, one to hold the current value, and one you are trying to reach. Try that now?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1