Advertisement
Guest User

Python Quiz: Are you depressed?

a guest
Aug 23rd, 2014
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env python
  2. import sys
  3.  
  4. DISCLAIMER = '''
  5.  
  6. CAUTION: THIS IS NOT A PROFESSIONAL ASSESSMENT. DO NOT SEEK MEDICATION WITHOUT
  7.         FIRST RECEIVING A PROFESSIONAL MEDICAL ASSESSMENT. THESE QUESTIONS AND
  8.         RESULTS HAVE BEEN GATHERED FROM THE INTERNET.
  9.  
  10. '''
  11.  
  12. def show_options():
  13.     options = [
  14.         'Not at all',
  15.         'Just a little',
  16.         'Somewhat',
  17.         'Moderately',
  18.         'Quite a lot',
  19.         'Very much',
  20.     ]
  21.     print
  22.     print 'Your options are:'
  23.     for i, option in enumerate(options):
  24.         print '\t%d. '%(i + 1) + option
  25.     print 'Type \'quit\' without quotes to quit early.'
  26.     print 'Type \'help\' to see this help again.'
  27.  
  28. def process(score):
  29.     if score < 9*3: return 'No depression likely'
  30.     if score < 9*4: return 'Possibly Mildly Depressed'
  31.     if score < 9*5: return 'Borderline Depression'
  32.     if score < 9*6: return 'Mild-Moderate Depression'
  33.     if score < 9*7: return 'Moderate-Severe Depression'
  34.     else: return 'Severely Depressed'
  35.  
  36. def main():
  37.     questions = [
  38.         'I do things slowly.',
  39.         'My future seems hopeless.',
  40.         'It is hard for me to concentrate on reading.',
  41.         'The pleasure and joy has gone out of my life.',
  42.         'I have difficulty making decisions.',
  43.         'I have lost interest in aspects of my life that used to be important to me.',
  44.         'I feel sad, blue, and unhappy.',
  45.         'I am agitated and keep moving around.',
  46.         'I feel fatigued.',
  47.         'It takes great effort for me to do simple things.',
  48.         'I feel that I am a guilty person who deserves to be punished.',
  49.         'I feel like a failure.',
  50.         'I feel lifeless more dead than alive.',
  51.         'I\'m getting too much, too little or not enough restful sleep.',
  52.         'I spend time thinking about HOW I might kill myself.',
  53.         'I feel trapped or caught.',
  54.         'I feel depressed even when good things happen to me.',
  55.         'Without trying to diet, I have lost or gained weight.',
  56.     ]
  57.  
  58.     print 'Are you depressed? Take this quick quiz to find out!'
  59.     print 'You will be given 18 statements, and must rate how well each statement'
  60.     print 'describes yourself on a scale from 1 to 6.'
  61.     print
  62.     print 'Start on the path of self discovery!'
  63.     show_options()
  64.  
  65.     score = 0
  66.     for i, question in enumerate(questions):
  67.         print
  68.         while True:
  69.             prompt = '%d) '%(i + 1) + question + ' : '
  70.             response = raw_input(prompt)
  71.         if len(response) == 1 and 48 < ord(response) < 54:
  72.                 score += int(response)
  73.                 break
  74.             elif response == 'help':
  75.                 show_options()
  76.             elif response == 'quit':
  77.                 print 'bye bye'
  78.                 sys.exit(0)
  79.             else:
  80.                 print 'Did not understand your response!'
  81.                 print 'Please try again. Type \'help\' for more info.'
  82.    
  83.     print
  84.     print 'Your Score: %d' % score
  85.     print 'Score Meaning: ' + process(score)
  86.     print DISCLAIMER
  87.  
  88. if __name__ == '__main__':
  89.     main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement