Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: I need help with my Python Program

                  
   
  1. #1

    Default I need help with my Python Program

    I'm making a multi-purpose program in Python. I need help with the password guessing part of it. No matter what is entered it always says its correct. If anyone can help me with that and tell me how to make it into a program that you dont need to have python to run. Thx in advance

  2. #2
    DCEmu Coder splodger15's Avatar
    Join Date
    Jun 2006
    Location
    London
    Age
    33
    Posts
    4,123
    Rep Power
    93

    Default

    Why start two threads of this

    PSN ID: splodger15

  3. #3
    GP2X Coder/Moderator
    Join Date
    Jan 2006
    Posts
    1,678
    Rep Power
    85

    Default

    Since you haven't posted the code, it isn't possible to help you with the first problem.

  4. #4

    Default

    yea i cant post the code until later because its at my grandmas house on her laptop and i dont have it here. ill post it next time i go over there. and how did you learn so many coding languages?

  5. #5
    GP2X Coder/Moderator
    Join Date
    Jan 2006
    Posts
    1,678
    Rep Power
    85

    Default

    All the languages are from the same or similar paradigm so the only real difference between the languages is the syntax (and some minor naunces with the language). Once you get the concept and thinking process behind what you program, the language doesn't matter.

  6. #6

    Default

    ok sry this has taken so long. hopefuly you can still help me. heres my code so far. plus i would like to know what i did wrong and know how to convert it to where you dont need python to run it. To where u can run it like a normal game. EDIT::For some reason it wont do the indents. but all the indents are correct. that much i know. the problem is in the code itself
    ------------------------------------------------------------------
    # This is my first program ever written by Young Prodigy on 11-17-06
    # Also a multi-purpose program

    def print_options():
    print "Options:"
    print " 'p' print options"
    print " 'c' convert from celsius"
    print " 'f' convert from fahrenheit"
    print " 'w' play password guessing game"
    def celsius_to_fahrenheit(c_temp):
    return 9.0/5.0*c_temp+32

    def fahrenheit_to_celsius(f_temp):
    return (f_temp - 32.0)*5.0/9.0

    choice = "p"
    while choice !="q":
    if choice == "c":
    temp = input("Celsius Temperature:")
    print "Fahrenheit:",celsius_to_fahrenheit(temp)
    elif choice == "f":
    temp = input("Fahrenheit Temperature:")
    print "Celsius:",fahrenheit_to_celsius(temp)
    elif choice != "q":
    print_options()
    choice = raw_input("option:")
    if choice == 'w':
    password = input("Guess the word:")
    def password(w_game):
    password = "143"

    while password != "143":
    password = raw_input("Type in what you think is the password:")

    print "So you got it, well let's try round 2"

    password = "143"

    while password != "1992":
    password = raw_input("Let's see if you get this one:")
    print "Crap, you got it."
    print "You may pass:"

  7. #7
    GP2X Coder/Moderator
    Join Date
    Jan 2006
    Posts
    1,678
    Rep Power
    85

    Default

    Bear in mind that this is the first time I have used python:
    http://www.rafb.net/paste/results/EveTBy15.html (it be here for 24hours only)

    ef print_options():
    print "Options:"
    print " 'p' print options"
    print " 'c' convert from celsius"
    print " 'f' convert from fahrenheit"
    print " 'w' play password guessing game"

    def celsius_to_fahrenheit(c_temp):
    return 9.0/5.0*c_temp+32

    def fahrenheit_to_celsius(f_temp):
    return (f_temp - 32.0)*5.0/9.0

    def password_game():
    password = raw_input("Guess the word:")

    while password != "143":
    password = raw_input("Type in what you think is the password:")

    print "So you got it, well let's try round 2"
    password = "143"

    while password != "1992":
    password = raw_input("Let's see if you get this one:")
    print "Crap, you got it."
    print "You may pass:"

    quit_program = 0

    while quit_program == 0:
    print_options()
    choice = raw_input("option:")

    if choice == "c":
    temp = input("Celsius Temperature:")
    print "Fahrenheit:",celsius_to_fahrenheit(temp)
    elif choice == "f":
    temp = input("Fahrenheit Temperature:")
    print "Celsius:",fahrenheit_to_celsius(temp)
    elif choice == 'w':
    password_game()
    elif choice == 'q':
    quit_program = 1
    The indents are pretty important and could change the logic flow, so without seeing the orignal source code with indents, I can't tell you exactly where you went wrong. Putting the function definition inside a logic block was hugely suspect.

    This might be what you are looking for as well: http://www.py2exe.org/

  8. #8
    DCEmu Legend gunntims0103's Avatar
    Join Date
    May 2006
    Location
    Brentwood, NY
    Age
    33
    Posts
    2,976
    Rep Power
    110

    Default

    yaustar i have to say you are quite a skilled coder. To understand a language the first time you glance at it is amazing. You truely understand basically all aspects of the language. I would pay for that skill.

  9. #9
    GP2X Coder/Moderator
    Join Date
    Jan 2006
    Posts
    1,678
    Rep Power
    85

    Default

    Thank you. It isn't so much learning a new language that is difficult, it is learning a new programming paradigm or programming methods. I know two which are Procedural programming and Object-oriented programming which thankfully a lot of languages use so I can adapt fairly quickly to them.

    Admittedly there are some minor quirks between languages of the same paradigm but eseentially, it is the same once you get past the syntax.

    The two that I would like to learn are Functional Programming and Logical Programming.

  10. #10
    DCEmu Legend gunntims0103's Avatar
    Join Date
    May 2006
    Location
    Brentwood, NY
    Age
    33
    Posts
    2,976
    Rep Power
    110

    Default

    well iv gotten execptionally better at lua and i adopted what you said to me a while back about logically going about your code and inplamenting a way to fix it. Such as in the cannabis guide my 2.0 release had no help and i just went about adding and fixing things with a logic stand piont of how the language works.

    Im taking up C++ i have a program already but its not in psp C++ format and i cant compile it....

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •