Skip to content

Instantly share code, notes, and snippets.

@deeagle
Last active May 25, 2016 13:56
Show Gist options
  • Save deeagle/bdcee193b392d111544834879e497a0c to your computer and use it in GitHub Desktop.
Save deeagle/bdcee193b392d111544834879e497a0c to your computer and use it in GitHub Desktop.
#! 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