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

guzdeh Group Title

Ola does anyone know why "!=" sometimes does not work / is a problem? Cannot figure out whats the problem. :S

  • one year ago
  • one year ago

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

    Doesn't work in what way? Can you provide an example?

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

    Its probably a syntax error you code, but provide an example so we can say it for sure.

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

    Hey guys I wrote this: n = input("Enter an exponent calculation base: ") m = input("Enter an exponent value: ") exp = n ** m for n != 0: print(exp) And it returned an error, problems with "!=". :S Now I have another question: Where do we submit our homework? :O

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

    for is used to repeat code usually 1 to n times...try: # if n is not 0 then print... if n != 0: print(exp) Hope this helps.

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

    @guzdeh you can't use "for" loop in that why. Look at professors lectures where you will see somethin like: for x in y: We don't submit our homework and I don't believe we do at all but maybe that changes. @darren66w in homework it says to use for loop so your code can't be used properly :)

    • one year ago
  6. darren66w Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    Thanks. Haven't read that homework. Not used to deliberately writing code that won't work.

    • one year ago
  7. darren66w Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    Now I'm confused as the homework doesn't say you can't use a conditional statement. I think I would write the following: n = raw_input("Enter an exponent calculation base: ") m = raw_input("Enter an exponent value: ") n = int(n) m = int(m) #loop once for x in range(1,2): if n != 0: exp = n ** m print exp else: print 'base is 0'

    • one year ago
  8. zlatandebian Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    while I don't encourage posting finished codes I think it should be something like this: e = int(raw_input("Base:")) g = int(raw_input("Exp:")) for y in g,e: y = e**g print y break

    • one year ago
  9. darren66w Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    zlatandebian good solution; not used to using for loops like that.

    • one year ago
  10. zlatandebian Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    @darren6w I can't say I am used to anything as this is my first true time doing coding, but I guess I will learn mistakes and make good solutions by trying stuff on my own :)

    • one year ago
  11. guzdeh Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    hey guys thanks a lot. :)

    • one year ago
  12. guzdeh Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    zlatan I am trying to reach you on skype. :)

    • one year ago
  13. saurav151 Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    @guzdeh your syntex of for is wrong. you should use ""if" statement at that place. structure of "for" is for(initial value;condition;increament).

    • one year ago
  14. darren66w Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    Just going through homework, I wonder if the following is what is actually required. Is definitely a more normal use of a for loop. NB code below does not work for negative exponents e.g. will require conditional statement to cover power of -2, -3... Also not sure how we know we have a suitable answer... base = int(raw_input("Base:")) exp = int(raw_input("Exp:")) for x in range(1,abs(exp)): base = base * base print base

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