Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,150,848 members, 7,810,267 topics. Date: Saturday, 27 April 2024 at 03:47 AM

Python CBT Program - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Python CBT Program (1770 Views)

CBT Software For Secondary Schools / CBT Web Application. A Competent Developer Needed. / CBT In Python. V2 By Fleshbone (2) (3) (4)

(1) (Reply) (Go Down)

Python CBT Program by fleshbone(m): 6:15pm On May 21, 2017
Hello Python friends


I created a CBT program with Python. I would be glad to learn how to do more with few codes.

I also think some of us can learn from it too.


from time import time,sleep


my_questions = dict()
my_answer = dict()

#Answer 1
my_answer['1'] = 'b'
#Answer 2
my_answer['2'] = 'c'
#Answer 3
my_answer['3'] = 'b'
#Answer 4
my_answer['4'] = 'c'
#Answer 5
my_answer['5'] = 'a'


#Question 1
my_questions['q_1'] = 'A paragraph inprose is equivalent to a?'
my_questions['q_1a'] = 'A. Verse in a poetry'
my_questions['q_1b'] = 'B. Stanza in poetry'
my_questions['q_1c'] = 'C. Metre in poetry'
my_questions['q_1d'] = 'D. Trope in poetry'

#Question 2
my_questions['q_2'] = 'The continuation of meaning without pause, from one line to the next is?'
my_questions['q_2a'] = 'A. Synecdoche'
my_questions['q_2b'] = 'B. Melodrama'
my_questions['q_2c'] = 'C. Enjambment'
my_questions['q_2d'] = 'D. Alliteration'

#Question 3
my_questions['q_3'] = 'Satire employs the use of?'
my_questions['q_3a'] = 'A. Onomatopia'
my_questions['q_3b'] = 'B. Irony'
my_questions['q_3c'] = 'C. Synecdoche'
my_questions['q_3d'] = 'D. Melancholy'

#Question 4
my_questions['q_4'] = 'The speech made by a character to himself on stage is?'
my_questions['q_4a'] = 'A. Epilogue'
my_questions['q_4b'] = 'B. Aside'
my_questions['q_4c'] = 'C. Soliloguy'
my_questions['q_4d'] = 'D. Monologue'

#Question 5
my_questions['q_5'] = 'A literary work that teaches moral is said to be?'
my_questions['q_5a'] = 'A. Didactic'
my_questions['q_5b'] = 'B. Intructive'
my_questions['q_5c'] = 'C. Corrective'
my_questions['q_5d'] = 'D. Impressive'

def candidate_name():
print 'Please enter your name:'
name = str(raw_input())
return name

def salutation():
print ''
print ''
print ('Hello ' + candidate_name().upper() + ', You Accessment Start in a While')
print ''
print 'Literature-in-English'
print ''

def answer(x):



answer_char = ['a','b','c','d','A','B','C','D']
print 'Enter a Character'
answer = str(raw_input())
if len(answer) > 1:
while len(answer) != 1:
print 'You Did not enter a character'
answer = str(raw_input())

if answer in answer_char:

if my_answer[str(x)] == answer.lower():

return 1

else:
while answer not in answer_char:
print 'the charcter is not part of the options.'
print 'Enter the right character'
answer = str(raw_input())
return 0

def quest():
score = 0
for x in range (1,6):
print ('Question ' + str(x))
print ''
print (my_questions['q_'+ str(x) ])
print ''
print (my_questions['q_'+ str(x) +'a'])
print (my_questions['q_'+ str(x) +'b'])
print (my_questions['q_'+ str(x) +'c'])
print (my_questions['q_'+ str(x) +'d'])
print ''

score += int(answer(x))

if x == 5:
if score == 5:
print ''
print 'Amazing!'
elif score == 4:
print ''
print 'Excellent!'
elif score == 3:
print ''
print 'Good!'
elif score == 2:
print ''
print 'Fair!'
elif score == 1:
print ''
print 'Poor!'
else:
print ''
print 'Very Poor!'
print ''
print ( 'Your Score is ' + str(score))
print ''
def main():
#candidate_name()

salutation()

start_time = time()

quest()

print ('You Spent ' + str((time() - start_time)/60) + ' Minuites')


main()





----------------------------------------------------------------------------------------------------------

This I wrote with Python 2.7

If I successfully build the desktop application version of it using TKInter module, I shall post it here as well God Willing.


phililp am sure you can easily re-write this into Python 3.

Anyone who can Should please re-write this into python 3 so we can all learn.

Cheers.
Re: Python CBT Program by phililp(m): 7:01pm On May 21, 2017
fleshbone:
Hello Python friends


I created a CBT program with Python. I would be glad to learn how to do more with few codes.

I also think some of us can learn from it too.


from time import time,sleep


my_questions = dict()
my_answer = dict()

#Answer 1
my_answer['1'] = 'b'
#Answer 2
my_answer['2'] = 'c'
#Answer 3
my_answer['3'] = 'b'
#Answer 4
my_answer['4'] = 'c'
#Answer 5
my_answer['5'] = 'a'


#Question 1
my_questions['q_1'] = 'A paragraph inprose is equivalent to a?'
my_questions['q_1a'] = 'A. Verse in a poetry'
my_questions['q_1b'] = 'B. Stanza in poetry'
my_questions['q_1c'] = 'C. Metre in poetry'
my_questions['q_1d'] = 'D. Trope in poetry'

#Question 2
my_questions['q_2'] = 'The continuation of meaning without pause, from one line to the next is?'
my_questions['q_2a'] = 'A. Synecdoche'
my_questions['q_2b'] = 'B. Melodrama'
my_questions['q_2c'] = 'C. Enjambment'
my_questions['q_2d'] = 'D. Alliteration'

#Question 3
my_questions['q_3'] = 'Satire employs the use of?'
my_questions['q_3a'] = 'A. Onomatopia'
my_questions['q_3b'] = 'B. Irony'
my_questions['q_3c'] = 'C. Synecdoche'
my_questions['q_3d'] = 'D. Melancholy'

#Question 4
my_questions['q_4'] = 'The speech made by a character to himself on stage is?'
my_questions['q_4a'] = 'A. Epilogue'
my_questions['q_4b'] = 'B. Aside'
my_questions['q_4c'] = 'C. Soliloguy'
my_questions['q_4d'] = 'D. Monologue'

#Question 5
my_questions['q_5'] = 'A literary work that teaches moral is said to be?'
my_questions['q_5a'] = 'A. Didactic'
my_questions['q_5b'] = 'B. Intructive'
my_questions['q_5c'] = 'C. Corrective'
my_questions['q_5d'] = 'D. Impressive'

def candidate_name():
print 'Please enter your name:'
name = str(raw_input())
return name

def salutation():
print ''
print ''
print ('Hello ' + candidate_name().upper() + ', You Accessment Start in a While')
print ''
print 'Literature-in-English'
print ''

def answer(x):



answer_char = ['a','b','c','d','A','B','C','D']
print 'Enter a Character'
answer = str(raw_input())
if len(answer) > 1:
while len(answer) != 1:
print 'You Did not enter a character'
answer = str(raw_input())

if answer in answer_char:

if my_answer[str(x)] == answer.lower():

return 1

else:
while answer not in answer_char:
print 'the charcter is not part of the options.'
print 'Enter the right character'
answer = str(raw_input())
return 0

def quest():
score = 0
for x in range (1,6):
print ('Question ' + str(x))
print ''
print (my_questions['q_'+ str(x) ])
print ''
print (my_questions['q_'+ str(x) +'a'])
print (my_questions['q_'+ str(x) +'b'])
print (my_questions['q_'+ str(x) +'c'])
print (my_questions['q_'+ str(x) +'d'])
print ''

score += int(answer(x))

if x == 5:
if score == 5:
print ''
print 'Amazing!'
elif score == 4:
print ''
print 'Excellent!'
elif score == 3:
print ''
print 'Good!'
elif score == 2:
print ''
print 'Fair!'
elif score == 1:
print ''
print 'Poor!'
else:
print ''
print 'Very Poor!'
print ''
print ( 'Your Score is ' + str(score))
print ''
def main():
#candidate_name()

salutation()

start_time = time()

quest()

print ('You Spent ' + str((time() - start_time)/60) + ' Minuites')


main()





----------------------------------------------------------------------------------------------------------

This I wrote with Python 2.7

If I successfully build the desktop application version of it using TKInter module, I shall post it here as well God Willing.


phililp am sure you can easily re-write this into Python 3.

Anyone who can Should please re-write this into python 3 so we can all learn.

Cheers.
aye! aye! capt. am working on it..

have you ran the code and it worked??
Re: Python CBT Program by fleshbone(m): 7:12pm On May 21, 2017
phililp:
aye! aye! capt. am working on it..
have you ran the code and it worked??


Yes Sir! Worked pretty well!

1 Like

Re: Python CBT Program by kraciprogrammer: 11:03pm On May 21, 2017
following

2 Likes

Re: Python CBT Program by antieverything(m): 11:11pm On May 21, 2017
fleshbone:
Hello Python friends

from time import time,sleep
import re
import decimal

my_questions = dict()
my_answer = dict()

#Answer 1
my_answer['1'] = 'b'
#Answer 2
my_answer['2'] = 'c'
#Answer 3
my_answer['3'] = 'b'
#Answer 4
my_answer['4'] = 'c'
#Answer 5
my_answer['5'] = 'a'


#Question 1
my_questions['q_1'] = 'A paragraph inprose is equivalent to a?'
my_questions['q_1a'] = 'A. Verse in a poetry'
my_questions['q_1b'] = 'B. Stanza in poetry'
my_questions['q_1c'] = 'C. Metre in poetry'
my_questions['q_1d'] = 'D. Trope in poetry'

#Question 2
my_questions['q_2'] = 'The continuation of meaning without pause, from one line to the next is?'
my_questions['q_2a'] = 'A. Synecdoche'
my_questions['q_2b'] = 'B. Melodrama'
my_questions['q_2c'] = 'C. Enjambment'
my_questions['q_2d'] = 'D. Alliteration'

#Question 3
my_questions['q_3'] = 'Satire employs the use of?'
my_questions['q_3a'] = 'A. Onomatopia'
my_questions['q_3b'] = 'B. Irony'
my_questions['q_3c'] = 'C. Synecdoche'
my_questions['q_3d'] = 'D. Melancholy'

#Question 4
my_questions['q_4'] = 'The speech made by a character to himself on stage is?'
my_questions['q_4a'] = 'A. Epilogue'
my_questions['q_4b'] = 'B. Aside'
my_questions['q_4c'] = 'C. Soliloguy'
my_questions['q_4d'] = 'D. Monologue'

#Question 5
my_questions['q_5'] = 'A literary work that teaches moral is said to be?'
my_questions['q_5a'] = 'A. Didactic'
my_questions['q_5b'] = 'B. Intructive'
my_questions['q_5c'] = 'C. Corrective'
my_questions['q_5d'] = 'D. Impressive'

def candidate_name():
name = input('Please enter your name: ')
return name

def salutation():
print ('\n\nHello ', candidate_name().upper() ,' You Accessment Start in a While')
print ('\nLiterature-in-English\n')

def answer(x):
answer_char = ['a','b','c','d']
answer = input('\nEnter a Character: ')
while (answer.lower() not in answer_char):
answer = input('You Did not enter a Valid character\n Enter A Character: ')
answer=re.sub(r"[^a-z]","",answer.lower()) #strip period numbers etc
if my_answer[str(x)] == answer.lower():
return 1
else:
return 0

def quest():
score = 0
for x in range (1,6):
print ('Question ',str(x))
print ()
print (my_questions['q_'+ str(x) ])
print ()
print (my_questions['q_'+ str(x) +'a'])
print (my_questions['q_'+ str(x) +'b'])
print (my_questions['q_'+ str(x) +'c'])
print (my_questions['q_'+ str(x) +'d'])
print ()

score += int(answer(x))

if x == 5:
if score == 5:
print ()
print ('Amazing!')
elif score == 4:
print ()
print ('Excellent!')
elif score == 3:
print ('')
print ('\nGood!')
elif score == 2:
print ('\nFair!')
elif score == 1:
print ('\nPoor!')
else:
print ('\nVery Poor!')
print ()
print ( 'Your Score is ' ,str(score))
print ()
def main():
#candidate_name()

salutation()

start_time = time()

quest()

total_time=decimal.Decimal((time() - start_time)/60)
total_time=round(total_time,2)
total_time_test=total_time * 100/60
if int(total_time_test) >= 1:
Timed="Minutes"
else:
Timed="Seconds"
total_time=total_time * 100

print ('You Spent ',total_time,Timed)


main()

1 Like

Re: Python CBT Program by fleshbone(m): 5:59am On May 22, 2017
antieverything

This is quite impressive, thanks for sharing the knowledge of regular expression on python. And the 'escape newline', please does that work on python 2.7?

Very impressive bro.
Thanks for sharing once more
Re: Python CBT Program by antieverything(m): 6:14am On May 22, 2017
fleshbone:
antieverything

This is quite impressive, thanks for sharing the knowledge of regular expression on python. And the 'escape newline', please does that work on python 2.7?

Very impressive bro.
Thanks for sharing once more
m pretty sure it works on 2.7
Re: Python CBT Program by fleshbone(m): 8:21am On May 22, 2017
antieverything:
m pretty sure it works on 2.7
Thanks a lot.
Re: Python CBT Program by airsaylongcon: 12:17am On May 28, 2017
Is this project purely for you to learn Python? Or are you planning to take this to another level?
Re: Python CBT Program by fleshbone(m): 4:19am On May 28, 2017
airsaylongcon:
Is this project purely for you to learn Python? Or are you planning to take this to another level?

We're actually just learning here. Anyone is allowed to take it to another level!

(1) (Reply)

. / Looking For Frontend, Backend Or Full Stack Developers - Where Do I Find Them? / MESA Compile?

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 39
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.