Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
REVIEW
#1
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
Reply
#2
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.
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020