/+junk/Dataanalys

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/%2Bjunk/Dataanalys

« back to all changes in this revision

Viewing changes to awnser_sheet.py

  • Committer: Gusatv Hartvigsson
  • Date: 2011-02-08 13:48:12 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20110208134812-b61fni3hgl2zyei8
finnished the section, I hope... now only the data annalasys is left.
and then QC I ald QC II.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
class awnserSheet:
13
13
        """" This returns the sql string that is built up during the prosses """
14
14
        sqlString = str(" ") # the strin that is going to be commited.
15
 
        sqlStringStart = """insert into awnsers(
16
 
"gudar",
17
 
"spoken",
18
 
"religos",
19
 
"sekulart",
20
 
"vegan",
21
 
"mars",
22
 
"globaluppvarmning",
23
 
"manen",
24
 
"motion",
25
 
"sund",
26
 
"deprimerad_host",
27
 
"sno",
28
 
"oppet",
29
 
"dodsstraff",
30
 
"kvinnors_rattigheter",
31
 
"abort",
32
 
"kvinnors_kropp",
33
 
"deprimerad_var",
34
 
"gast_sverige",
35
 
"fodd_sverige",
36
 
"foraldrar_sverige",
37
 
"komentarer"
38
 
)
39
 
values("""
 
15
        
 
16
        ##This brings in the values and the sql string from sqlAwnsersStrat
 
17
        # and uses them as a string.
 
18
        f = open("./sqlAwnsersStart.sql")
 
19
        sqlStringStart = f.read()
 
20
        f.close()
 
21
        
40
22
        sqlStringEnd = ");"
41
23
        
42
24
        
47
29
                if(q != "0" and q != "1"):
48
30
                        print("!!! the input is invalid !!! \n !!! Try again !!!")
49
31
                        return("-1")
50
 
                
51
 
                return(q)
 
32
                else:
 
33
                        return(q)
52
34
                
53
35
        ## end question input
54
36
        ## start addToSqlString
55
37
        def addToSqlString(q):
56
38
                """ This function just adds to the sqlstring the value of q """
57
 
                awnserSheet.sqlString = awnserSheet.sqlString + " " + str(q) + ", "
 
39
                awnserSheet.sqlString = awnserSheet.sqlString + str(q) + str(", ")
58
40
        ## end addToSqlString
59
41
        ##start suestions section
60
42
        def question1():
 
43
                awnserSheet.sqlString = str(" ") # string cleanup!
61
44
                print("Fråga 1:")
62
45
                print("Tror du på en/flera personlig(a) gud/gudar?")
63
46
                q = awnserSheet.qinput()
64
47
                if(q == "-1"):
65
48
                        awnserSheet.question1()
66
49
                else:
67
 
                        awnserSheet.addToSqlString(q)
 
50
                        awnserSheet.addToSqlString(int(q))
68
51
                
69
52
        
70
53
        def question2():
74
57
                if(q == "-1"):
75
58
                        awnserSheet.question2()
76
59
                else:
77
 
                        awnserSheet.addToSqlString(q)
 
60
                        awnserSheet.addToSqlString(int(q))
78
61
                
79
62
        
80
63
        def question3():
84
67
                if(q == "-1"):
85
68
                        awnserSheet.question3()
86
69
                else:
87
 
                        awnserSheet.addToSqlString(q)
 
70
                        awnserSheet.addToSqlString(int(q))
88
71
                
89
72
        
90
73
        def question4():
91
74
                print("Fråga 4:")
92
 
                print("är du för ett sekelärt samhälle?")
 
75
                print("är du för ett sekulärt samhälle?")
93
76
                q = awnserSheet.qinput()
94
77
                if(q == "-1"):
95
78
                        awnserSheet.question4()
96
79
                else:
97
 
                        awnserSheet.addToSqlString(q)
 
80
                        awnserSheet.addToSqlString(int(q))
98
81
                
99
82
        
100
83
        def question5():
104
87
                if(q == "-1"):
105
88
                        awnserSheet.question5()
106
89
                else:
107
 
                        awnserSheet.addToSqlString(q)
 
90
                        awnserSheet.addToSqlString(int(q))
108
91
                
109
92
        
110
93
        def question6():
114
97
                if(q == "-1:"):
115
98
                        awnserSheet.question6()
116
99
                else:
117
 
                        awnserSheet.addToSqlString(q)
 
100
                        awnserSheet.addToSqlString(int(q))
118
101
                
119
102
        
120
103
        def question7():
124
107
                if(q == "-1"):
125
108
                        awnserSheet.question7()
126
109
                else:
127
 
                        awnserSheet.addToSqlString(q)
 
110
                        awnserSheet.addToSqlString(int(q))
128
111
                
129
112
        
130
113
        def question8():
131
 
                print("Fråga 9:")
 
114
                print("Fråga 8:")
132
115
                print("Tror du att vi varit på månen?")
133
116
                q = awnserSheet.qinput()
134
117
                if(q == "-1"):
135
118
                        awnserSheet.question8()
136
119
                else:
137
 
                        awnserSheet.addToSqlString(q)
 
120
                        awnserSheet.addToSqlString(int(q))
138
121
                
139
122
        
140
123
        def question9():
141
 
                print("Fråga 10:")
 
124
                print("Fråga 9:")
142
125
                print("Motionerar du regelbundet?")
143
126
                q = awnserSheet.qinput()
144
 
                if(q == " -1"):
 
127
                if(q == "-1"):
145
128
                        awnserSheet.question9()
146
129
                else:
147
 
                        awnserSheet.addToSqlString(q)
 
130
                        awnserSheet.addToSqlString(int(q))
148
131
                
149
132
        
150
133
        def question10():
151
134
                print("Fråga 10:")
152
135
                print("Anser du att du har en sund livsstil?")
153
136
                q = awnserSheet.qinput()
154
 
                if(q == " -1"):
 
137
                if(q == "-1"):
155
138
                        awnserSheet.question10()
156
139
                else:
157
 
                        awnserSheet.addToSqlString(q)
 
140
                        awnserSheet.addToSqlString(int(q))
158
141
                
159
142
        
160
143
        def question11():
161
144
                print("Fråga 11:")
162
145
                print("Blir du deprimerad/nedstämd på hösten/vintern?")
163
146
                q = awnserSheet.qinput()
164
 
                if(q == " -1"):
 
147
                if(q == "-1"):
165
148
                        awnserSheet.question11()
166
149
                else:
167
 
                        awnserSheet.addToSqlString(q)
 
150
                        awnserSheet.addToSqlString(int(q))
168
151
                
169
152
        
170
153
        def question12():
171
154
                print("Fråga 12:")
172
155
                print("Gillar du snö?")
173
156
                q = awnserSheet.qinput()
174
 
                if(q == " -1"):
 
157
                if(q == "-1"):
175
158
                        awnserSheet.question12()
176
159
                else:
177
 
                        awnserSheet.addToSqlString(q)
 
160
                        awnserSheet.addToSqlString(int(q))
178
161
                
179
162
        
180
163
        def question13():
181
164
                print("Fråga 13:")
182
165
                print("Är du för ett öppet samhälle?")
183
166
                q = awnserSheet.qinput()
184
 
                if(q == " -1"):
 
167
                if(q == "-1"):
185
168
                        awnserSheet.question13()
186
169
                else:
187
 
                        awnserSheet.addToSqlString(q)
 
170
                        awnserSheet.addToSqlString(int(q))
188
171
                
189
172
        
190
173
        def question14():
191
174
                print("Fråga 14:")
192
175
                print("Är du för dödsstraff?")
193
176
                q = awnserSheet.qinput()
194
 
                if(q == " -1"):
 
177
                if(q == "-1"):
195
178
                        awnserSheet.question14()
196
179
                else:
197
 
                        awnserSheet.addToSqlString(q)
 
180
                        awnserSheet.addToSqlString(int(q))
198
181
                
199
182
        
200
183
        def question15():
201
184
                print("Fråga 15:")
202
185
                print("Är du för kvinnors rättigheter?")
203
186
                q = awnserSheet.qinput()
204
 
                if(q == " -1"):
 
187
                if(q == "-1"):
205
188
                        awnserSheet.question15()
206
189
                else:
207
 
                        awnserSheet.addToSqlString(q)
 
190
                        awnserSheet.addToSqlString(int(q))
208
191
                
209
192
        
210
193
        def question16():
211
194
                print("Fråga 16:")
212
195
                print("Är du för abort?")
213
196
                q = awnserSheet.qinput()
214
 
                if(q == " -1"):
 
197
                if(q == "-1"):
215
198
                        awnserSheet.question16()
216
199
                else:
217
 
                        awnserSheet.addToSqlString(q)
 
200
                        awnserSheet.addToSqlString(int(q))
218
201
                
219
202
        
220
203
        def question17():
221
204
                print("Fråga 17:")
222
205
                print("Är du för kvinnors rätt att bestämma över sin egen kropp?")
223
206
                q = awnserSheet.qinput()
224
 
                if(q == " -1"):
 
207
                if(q == "-1"):
225
208
                        awnserSheet.question17()
226
209
                else:
227
 
                        awnserSheet.addToSqlString(q)
 
210
                        awnserSheet.addToSqlString(int(q))
228
211
                
 
212
        
229
213
        def question18():
230
214
                print("Fråga 18:")
231
215
                print("Blir du deprimerad/nedstämd på våren?")
232
216
                q = awnserSheet.qinput()
233
 
                if(q == " -1"):
234
 
                        awnserSheet.question18()
235
 
                else:
236
 
                        awnserSheet.addToSqlString(q)
 
217
                if(q == "-1"):
 
218
                        awnserSheet.question18()
 
219
                else:
 
220
                        awnserSheet.addToSqlString(int(q))
 
221
                
 
222
        
 
223
        def question19():
 
224
                print("Fråga 19:")
 
225
                print("Tror du på den vetenskapliga metoden?")
 
226
                q = awnserSheet.qinput()
 
227
                if(q == "-1"):
 
228
                        awnserSheet.question18()
 
229
                else:
 
230
                        awnserSheet.addToSqlString(int(q))
 
231
                
 
232
        
 
233
        def question20():
 
234
                print("Fråga 20:")
 
235
                print("""Tror du att evolutionen som beskrivs i den mordärna
 
236
vetenskapen är ursprunget till de många arterna på denna planet?""")
 
237
                q = awnserSheet.qinput()
 
238
                if(q == "-1"):
 
239
                        awnserSheet.question18()
 
240
                else:
 
241
                        awnserSheet.addToSqlString(int(q))
237
242
                
238
243
        
239
244
        def questionI():
240
245
                print("Fråga I:")
241
246
                print("Är du gäststuderande här i Sverige?")
242
247
                q = awnserSheet.qinput()
243
 
                if(q == " -1"):
 
248
                if(q == "-1"):
244
249
                        awnserSheet.questionI()
245
250
                else:
246
 
                        awnserSheet.addToSqlString(q)
 
251
                        awnserSheet.addToSqlString(int(q))
247
252
                
 
253
        
248
254
        def questionII():
249
255
                print("Fråga II")
250
256
                print("Är du född i Sverige?")
251
257
                q = awnserSheet.qinput()
252
 
                if(q == " -1"):
 
258
                if(q == "-1"):
253
259
                        awnserSheet.questionI()
254
260
                else:
255
 
                        awnserSheet.addToSqlString(q)
 
261
                        awnserSheet.addToSqlString(int(q))
256
262
                
 
263
        
257
264
        def questionIII():
258
265
                print("Fråga III")
259
266
                print("Är en eller båda av dina föreldrar inte födda i Sverige?")
260
267
                q = awnserSheet.qinput()
261
 
                if(q == " -1"):
 
268
                if(q == "-1"):
262
269
                        awnserSheet.questionI()
263
270
                else:
264
 
                        awnserSheet.addToSqlString(q)
 
271
                        awnserSheet.addToSqlString(int(q))
265
272
                
 
273
        
266
274
        def questionCommentry():
267
275
                print("Komentarer:")
268
276
                print("Skriv en komentar på denna undörsökning:")
269
 
                q = str(input(">>>>>>"))
 
277
                q = str(input(">>>>>> "))
270
278
                awnserSheet.sqlString = awnserSheet.sqlString + " \" " + str(q) + "\" "
271
279
        #
272
280
###
290
298
                awnserSheet.question16()
291
299
                awnserSheet.question17()
292
300
                awnserSheet.question18()
 
301
                awnserSheet.question19()
 
302
                awnserSheet.question20()
293
303
                awnserSheet.questionI()
294
304
                awnserSheet.questionII()
295
305
                awnserSheet.questionIII()
296
306
                awnserSheet.questionCommentry()
297
307
                
298
 
                
299
308
                print("\n\n======================== tack och adjöken ^_^ ===================\n\n")
300
309
        
301
310
                return( awnserSheet.sqlStringStart + awnserSheet.sqlString + awnserSheet.sqlStringEnd )