RE: First program help 02-22-2014, 08:48 PM
#7
(02-22-2014, 08:43 PM)PrimeD Wrote: ok, i figured it out.
This is what I did to get it to work. Still, are there better ways that I could acomplish what I did.Code:age = int(input('How old are you: ')) x = age y = 33 sum = x+y
(02-22-2014, 08:40 PM)Ex094 Wrote: You can do it like this:
Code:age = input('How old are you: ') rage = random.randint(1, 100) weird = sum(age + rage)
Instead of 33, you can generate any random number using Python b/w a given range hence on every run the age will look weirder depending upon the generated number.
Nice, i thought about getting random numbers in there but have not got that far in the book. Thanks for showing me how.
Correct! I too just figured out that you hadn't converted the input to int because the input by default is set as a string so you'll have to convert it to int before passing it on to the sum function. Using random can be much fun




![[+]](https://sinister.li/images/modern/collapse_collapsed.png)