PDA

View Full Version : I need help with my Python Program



LilSwish722
November 24th, 2006, 21:49
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

splodger15
November 25th, 2006, 09:40
Why start two threads of this

yaustar
November 25th, 2006, 16:09
Since you haven't posted the code, it isn't possible to help you with the first problem.

LilSwish722
November 26th, 2006, 22:38
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?

yaustar
November 26th, 2006, 22:50
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.

LilSwish722
December 17th, 2006, 00:55
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:"

yaustar
December 17th, 2006, 02:30
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/

gunntims0103
December 17th, 2006, 02:38
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.

yaustar
December 17th, 2006, 02:52
Thank you. It isn't so much learning a new language that is difficult, it is learning a new programming paradigm (http://en.wikipedia.org/wiki/Programming_paradigms) or programming methods. I know two which are Procedural programming (http://en.wikipedia.org/wiki/Procedural_programming) and Object-oriented programming (http://en.wikipedia.org/wiki/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 (http://en.wikipedia.org/wiki/Functional_programming) and Logical Programming (http://en.wikipedia.org/wiki/Logical_programming).

gunntims0103
December 17th, 2006, 03:11
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....

LilSwish722
December 17th, 2006, 17:18
thanks alot guys. and can you tell me how to make it run like a normal computer program

yaustar
December 17th, 2006, 19:00
This might be what you are looking for as well: http://www.py2exe.org/
:rolleyes:

LilSwish722
December 17th, 2006, 19:34
haha sry about that. thanks for your help. im going to try it and see if it helped. If it doesn't can you help me som more, or if I want to add new features.