Assign values to answers from a questionnaire, input into a formula and calculate score I was wondering if anyone could make any suggestions to how I could write the following more concisely and reduce the number of IF statements? If possible, I would also like to simultaneously assign values to variables and calculate the score.

I will eventually have multiple rule sets and formula scores for other question sets.

# q001 is multiple choice with three choices - q001_a01, q001_a02 &amp; q001_a03 - only one selection can be made
# q002 is the first part of a two part question. It has two options = q002_a01 &amp; q002_a02 - again, only one selection can be made
# q003 is only answered if q002_a01 is selected in q002 and also has two choices - q003_a01 &amp; q003_a02
# q004 is a multiple choice question with 5 options - q004_a01, q004_a02, q004_a03, q004_a04 &amp; q004_a05 - multiple selections can be made, q004_a05 answer is 'none of the above' 
# q005 is a simple Yes/No (True/False) question
# q006 is multiple choice with three choices - q006_a01, q006_a02, q006_a03 &amp; q006_a004 - only one selection can be made
# q007 is multiple choice with three choices - q007_a01, q007_a02 &amp; q007_a03 - only one selection can be made
# q008 requires an input of an integer from 1-5
# all questions require a response (except q003)

# dictionary containing question and answer codes for a single individuals response
data = {'q001': 'q001_a01',
        'q002': 'q002_a01',
        'q003': 'q003_a02',
        'q004': ['q004_a01', 'q004_a02', 'q004_a04'],
        'q005': False,
        'q006': 'q006_a03',
        'q007': 'q007_a01',
        'q008': 3}

# rules which define the values of the different variables
var1 = 2 if 'q001_a01' in data['q001'] else 0
var1 = 5 if 'q001_a02' in data['q001'] or 'q001_a03' in data['q001'] else var1

var2 = -2 if 'q002_a01' in data['q002'] and 'q003_a01' in data['q003'] else 0
var2 = 2 if 'q002_a01' in data['q002'] and 'q003_a02' in data['q003'] else var2

var3 = 2 if 'q004_a01' in data['q004'] else 0
var3 = var3 + 2 if 'q004_a02' in data['q004'] else var3
var3 = var3 - 1 if 'q004_a03' in data['q004'] else var3
var3 = var3 + 1 if 'q004_a04' in data['q004'] else var3
var3 = 5 if 'q004_a05' in data['q004'] else var3

var4 = 4 if True is data['q005'] else 0

var5 = 1 if 'q006_a01' in data['q006'] else 0
var5 = 2 if 'q006_a02' in data['q006'] else var5
var5 = -10 if 'q006_a03' in data['q006'] else var5
var5 = -2 if 'q006_a04' in data['q006'] else var5

var6 = 2 if 'q007_a01' in data['q007'] else 0
var6 = 1 if 'q007_a02' in data['q007'] or 'q007_a03' in data['q007'] else var6

var7 = data['q008']

# formula to calculate score from variables
score = var1 + var2 + var3 + var4 + ((var5 + var6) * var7)


I would like to make the code as neat and fast as possible.
Also, could someone point me towards some python literature which would help me improve this myself?
Since everything in this code is defined statically rather than as a function input (and your comments indicate that there is no way to vary any part of how this code functions), there is no possibility allowed within the parameters of this question for the score to ever vary.  You can therefore make this code significantly more concise and efficient by simply computing the score statically:

score = -15


This will produce the same score result as your original code with a significantly smaller footprint.

If this doesn't seem right, the question to ask yourself (and then answer for the benefit of your code reviewers) is: which constants in this code can vary, and what types/values are permissible for them?