Login Register






First program help filter_list
Author
Message
RE: First program help #7
(02-22-2014, 08:43 PM)PrimeD Wrote: ok, i figured it out.
Code:
age = int(input('How old are you: ')) x = age y = 33 sum = x+y
This is what I did to get it to work. Still, are there better ways that I could acomplish what I did.

(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 Biggrin
My Blog: http://www.procurity.wordpress.com
Donations: 1HLjiSbnWMpeQU46eUVCrYdbkrtduX7snG

Reply





Messages In This Thread
First program help - by PrimeD - 02-22-2014, 07:54 PM
First program help - by PrimeD - 02-22-2014, 07:54 PM