Python Forum

Full Version: REVIEW
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Well I've made a small, simple, program in Python, can anyone tell me how to make it better, I'm still a nube.

Program:

import sys
Import random

U = True

while True:
Indent>> X = (random.randint(1,50))
Indent>> Y = (random.randint(60,100))
Indent>> Z = (random.randint(20,40))
indent>> A = (random.randint(X, Y))

Indent>> X2 = str(X)
Indent>> Y2 = str(Y)
Indent>> Z2 = str(Z)
Indent>> A2 = str(A)

Indent>> guess_count = 0

Indent>> answer = str(random.randint(X, Y)

indent>> Guess3 = (" and ")
indent>> Guess4 = (" guesses")
indent>> Guess2 = (". What do you think it is? You have ")
indent>> Guess1 = ("I'm thinking of a number between ")
indent>> Guess = (Guess1 + X2 + Guess3 + Y2 + Guess2)
indent>> second_guess = (Z2 + Guess4)
Indent>> Player = (Guess + second_guess)
indent>> print(Player)

Indent>> while guess_count < Z:
DoubleIndent>> checked = ("Guess" + ":")
doubleindent>> check = input(checked)
doubleindent>> guess_count = guess_count + 1

DoubleIndent>> if check < A2:
TripleIndent>> print("Go Higher")

Doubleindent>> if check > A2:
TripleIndent>> print("Go Lower")

DoubleIndent>> if check == A2:
TripleIndent>> break

DoubleIndent>> if check == A2:
TripleIndent>> guess_count = str(guess_count)
TripleIndent>> print("Cool, you guessed the number in", guess_count, "tries")
TripleIndent>> print("")

DoubleIndent>> if check != A2:
TripleIndent>> print("Nope, the number I was thinking of was", A2)
TripleIndent>> print("")


Heart
Follow the link in @burans message on how to post using BBCode. As it is, your code cannot be run to test it and give you any feedback, not to mention having to remove all the indents >>, double indents >> and triple indents >>.

Also, in this section it is a good idea to give a brief synopsis as to what your program does.

Remember, Python LOVES descriptive variables and will punish you in the future for using single letters or obscure ones.