[Tutor] Please sent me the output of this code .Please include both cases if input correct and if input wrong .
Alan Gauld
alan.gauld at btinternet.com
Sat Dec 5 17:47:36 EST 2015
On 05/12/15 18:48, Deepak Nn wrote:
> # Embedded file name: re4.py
If you want to know the output run it.
If the output you get is not what you expect tell us what you input,
what you got out, what you expec6ed.
Also tell us which OS and Python versions you are using.
Otherwise all I can tell you is that the output will be some combination
of the various print statements depending on
what input you provide(assuming there are no code errors).
> import time
> flag = [102,
> 108,
> 97,
> 103,
> 123,
> 112,
> 121,
> 116,
> 104,
> 111,
> 110,
> 95,
> 114,
> 111,
> 99,
> 107,
> 115,
> 125]
> password = raw_input('Enter secret code to get secret password: ')
> sleep_hours = 10000
> print 'Going to sleep. Will check password after %d hours' % sleep_hours
> print 'If you want to check password faster, find a way to prevent this
> sleep'
> time.sleep(sleep_hours * 60 * 60)
> if password == 'strongpassword':
> print 'Correct! The secret password is %s' % ''.join(map(chr, flag))
> else:
> print 'Booo wrong code! No secret password for you'
I suspect the question you really want to ask is about how the map()
function works? It will apply the chr() function to each number in flags.
>>> chr(102),chr(108),chr(97)
('f', 'l', 'a')
And so on.
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
More information about the Tutor
mailing list