I have been wanting to learn programming for some time now and decided to really give it a shot today. I have edited and read lots of things in Java to fix small issues but never written from scratch. I've tried C and Java but both seemed just a bit too much to teach myself as a first language, so I'm going with Python first.
Can anyone look through this little sample random number generator I made and point out anything I should be doing differently or correctly? It is executing without issues for me but I'm sure I've got extra nonsense in here. I just have all the prints to see a result of each step and I know this is not what a real random number generator would be like. I'm just testing and learning my way around different aspects of the language.
import random
x = int(raw_input("Please enter a number up to 100. "))
z = random.randint(40,100)
""" x and z can both be used below without errors -- testing/learning"""
randomNumber = random.randint(1,z)
print "first random",randomNumber
if 35 >= randomNumber:
newRandom = randomNumber * .5
newRandom = newRandom + 9
print "second random " "%.f" % newRandom
elif 36 <= randomNumber <= 93:
newRandom = randomNumber + 7
print "second random " "%.f" % newRandom
else:
newRandom = randomNumber
print "second random",newRandom
x
is initialized but never used)? If so, please include that aspect of the code without making any changes already mentioned in the answers. \$\endgroup\$random.randint(1,x|z)
for testing, so whilst I can't seeing it being used in the code above, it read it as it could be used there. \$\endgroup\$