peterdcasey

Untitled

Oct 23rd, 2017
343
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.65 KB | None | 0 0
  1.  
  2. # Asks for a stating day of the week
  3. # Returns that day as a str
  4. def get_day_leaving():
  5.     print('Enter a day of the week you plan to leave... i.e. "Monday"')
  6.     userInput  = input('Please enter a day of the week: ')
  7.     day = userInput.lower()
  8.     return day
  9.  
  10. # Takes the starting day from the user and finds it in "week"
  11. # Returns the index value of position in "week"
  12. def get_day_index(week, starting_day_result):
  13.     dayIndex = week.index(starting_day_result)
  14.     return dayIndex
  15.  
  16. # Asks for how many days to be gone
  17. # Returns the int
  18. def get_days_gone():
  19.     userInput = input('How many days will you be gone?: ')
  20.     daysGone = int(userInput)
  21.     return daysGone
  22.  
  23. # Adds the starting day index value from "week" with the amount of days to be gone
  24. # Return the total
  25. def add_days(index_result, days_gone_result):
  26.     startToEnd = index_result + days_gone_result
  27.     return startToEnd
  28.  
  29. # Input the total days gone
  30. # Return the day of the week returning
  31. def day_coming_back(week, days_gone):
  32.     dayBack = days_gone % len(week)
  33.     weekday_back = week[dayBack].capitalize()
  34.     return weekday_back
  35.  
  36. # Main Program
  37. def main_program():
  38.     #Days of the week
  39.     week = ['sunday', 'monday', 'tuesday', 'wednesday',
  40.             'thursday', 'friday', 'saturday']
  41.  
  42.     leaving_day = get_day_leaving() # starting day
  43.     leaving_day_index = get_day_index(week, leaving_day) # index value
  44.     days_gone = get_days_gone() # days gone
  45.     start_to_end = add_days(leaving_day_index, days_gone) # total of index and days gone
  46.     day_back = day_coming_back(week, start_to_end)
  47.     print('You will be back on a ' + day_back)
  48.  
  49. main_program()
Add Comment
Please, Sign In to add comment