Last active
May 25, 2016 13:56
-
-
Save deeagle/bdcee193b392d111544834879e497a0c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! pyhton3 | |
def get_file_as_line(filename): | |
"""Returns the whole content of a file as one line""" | |
print('Read file: {0}'.format(filename)) | |
with open(filename) as file_object: | |
lines = file_object.readlines() | |
content_string = '' | |
for line in lines: | |
content_string += line.rstrip() | |
return content_string | |
def get_birthday_from_user_input(): | |
"""Returns the birthday of a user in the format: ddMMyyyy""" | |
birthday = input('Enter your birthday, in the form ddMMyyyy: ') | |
return str(birthday) | |
filename = 'data_pi.txt' | |
#print(get_file_as_line(filename)) | |
birthday = get_birthday_from_user_input() | |
pi_string = get_file_as_line(filename) | |
if birthday in pi_string: | |
print('Your birthday appears in the first million digits of pi!') | |
else: | |
print('Your birthday does not appear in the first million digits of pi.') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment