Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,153,544 members, 7,819,934 topics. Date: Tuesday, 07 May 2024 at 07:03 AM

Fleshbone's Posts

Nairaland Forum / Fleshbone's Profile / Fleshbone's Posts

(1) (2) (3) (4) (5) (of 5 pages)

Programming / Re: CBT In Python. V2 By Fleshbone by fleshbone(m): 6:05pm On May 28, 2017
The Book. (Slide) am using for learning the GUI is 'An Introduction to GUI programming with Tkinter - Erik Spence'
Programming / Re: CBT In Python. V2 By Fleshbone by fleshbone(m): 5:59pm On May 28, 2017
kayoph:
Guys, this the link for my version:

https://github.com/olamigokayphils/CBT.py

Make sure to read the Readme

Review it. it's Open to criticism fam.

Here is the code Kayoph wants to display.



# For Niaraland Programming Thread
# CBT exam stuff
import sys
import time
from time import *
def open_file(file_name, mode):
""" Open the cbt.txt file. """
try:
the_file = open(file_name, mode)
except IOError as e:
print("Cannot locate the file", file_name, "Ending the program...", e)
sleep(2)
input("\n\nPress the enter key to exit. "wink
sys.exit()
else:
return the_file
def next_line(the_file):
"""This returns the next line from the cbt.txt file. """
line = the_file.readline()
line = line.replace("/", "\n"wink
return line
def next_block(the_file):
"""This return the next block of data from the file. """
category = next_line(the_file)
question = next_line(the_file)
answer = []
for i in range(4):
answer.append(next_line(the_file))
correct = next_line(the_file)
if correct:
correct = correct[0]
return category, question, answer, correct
def subject_selector():
print('please select the subject you want to start with\n')
subject = str(input('enter A - for Arigultural Science\n'
'enter B - for Biology\n'
'enter M - for Mathematics\n'
'enter C - for Chemistry\n'
'enter P - for Physics\n'
'enter G - for Geography\n'
'enter Eng - for English\n'
'enter N - for Nairaland CBT\n:'))
subject = subject.lower()
choice_char = ["n"]
while subject not in choice_char:
print("Only the file for Niaraland CBT was created. Abeg No vex!"wink
print("\nKindly select 'N' in the option"wink
subject = str(input('\nenter A - for Arigultural Science\n'
'enter B - for Biology\n'
'enter M - for Mathematics\n'
'enter C - for Chemistry\n'
'enter P - for Physics\n'
'enter G - for Geography\n'
'enter Eng - for English\n'
'enter N - for Nairaland CBT\n:'))
if subject == "n":
welcome()
def welcome():
"""welcome the student. """
print("\t\tWElcome to the nairaland CBT Examination.\n"wink
def dmain():
student_name = input("Enter your name to begin the test:"wink
while not student_name:
student_name = input("Enter your name to begin the test."wink
print(student_name, ", VERIFYING DETAILS..."wink
sleep(2)
subject_selector()
start = time()
cbt_file = open_file("cbt.txt", "r"wink
title = next_line(cbt_file)
score = 0
#getting the first block
category, question, answer, correct = next_block(cbt_file)
while category:
#the question
print(category)
print(question)
for i in range(4):
print("\t", i + 1, "-", answer[i])
#gettin the answer
answer = input("What is your answer?: "wink
#verify answer
if answer == correct:
score += 1
else:
score += 0
#getting the next_block
category, question, answer, correct = next_block(cbt_file)
cbt_file.close()
print("That was the last question!"wink
stop = time()
print("SUBMITTING..."wink
sleep(2)
print("Your Final score is", score, ", you used", stop - start, "seconds"wink
#Runniniggggggggggggggg
dmain()
input("\n\nPress the enter key to exit. "wink
Programming / Re: CBT In Python. V2 By Fleshbone by fleshbone(m): 2:31pm On May 28, 2017
TheLordIsGr8:


I guess you have a github account. Just post it on github and provide a link. Its the best way.


Sorry I didn't expect it to show that way.

Here is an html tag for code '<code>paste your code in here</code>'.

But instead of '<' use '['. And for '>', Use ']'.
Programming / Re: CBT In Python. V2 By Fleshbone by fleshbone(m): 1:02pm On May 28, 2017
kayoph:


Yea i will be working on it this night.. And see what's up in the morrow.



Yh, i have written my version last night. Also, I will try and work on the GUI this night.. But i don't know how to post it like phililp did.. I don't what the indentation compromised. Phililp, how did you post yours?


use this tag
 paste your code here 
Programming / 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!
Programming / Re: CBT In Python. V2 By Fleshbone by fleshbone(m): 3:11am On May 28, 2017
kayoph:
Philip, i ran the codes it was pretty clean. Except for some typos. it's okay wink.

But really, as for me i don't think writing a code for an exam and the [/b]questions seen to be contained in the codes[b] is "fresh". i will rather create a text_file on my PC and the Program access the text_file for the question and answer, i feel its neater and more okay. i'll try and work on this too + i think am interested in the GUI.

fleshbone , thanks for stirring something up.


We are actually all learning. Would love to see ur version of the program anyway so we can all get beTter. Thank to you too.

Am currently reading a book about GUI Using Tkinter module.

I would come up with something soon.
Programming / Re: CBT In Python. V2 By Fleshbone by fleshbone(m): 8:09pm On May 27, 2017
pythonkid:
Pls contact me in private

Sorry sir, I don't know how to send private messages here.
Programming / Re: CBT In Python. V2 By Fleshbone by fleshbone(m): 5:03pm On May 27, 2017
This is impressive boss (phililp)


Am not on a pc now, I would go through it better later in the day when am back home. Kudos.


antieverything should see this. Am sure he has a lot to share too.
Islam for Muslims / Re: Why Will Sultan Always Be The One To Declare Fasting For A Whole Nation..? by fleshbone(m): 4:18pm On May 27, 2017
Because in Islam, a movement without a leader is one of hypocrites.

Everyone is tasked with sighting the moon. But the leader okays it provided the person who sighted it can be trusted.

The month is used to count daYs and a new moon signifies a new month.

The Sultan as the leader then gives a go ahead. If he doesn't, Fasting can't commence.

24 Likes

Islam for Muslims / Re: Ramadan Fasting; Saudi Arabia Announces Date For Commencement by fleshbone(m): 7:54am On May 26, 2017
Saudi Arabia is not the birth place of Islam. Islam has always being there away from the arabian peninsula.

Masha Allah. Ramadan is finally here again!

2 Likes 1 Share

Programming / Re: Help Me! I Need An IDE by fleshbone(m): 12:12am On May 23, 2017
phililp:
dear nairagrammers...

when i staryted learning python i downloaded an IDE(pycharm) which was very cool and helped me learnt very fast..

but unfortunately for me.. i was only evaluating.. which just expired... jetbrain said one needs a licence to activate it and they give free to students... i tried applying but they said they dont recognise me email..

pls help me am going down. is there any free IDE that i can use?? i mean FREE...

tired of using python shell... dosent work as desired..

help a broda


fleshbone.. come in.


I use IDLE 2.7. But you should download IDLE 3 since you use Python 3 to program.
Programming / 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.
Programming / 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
Programming / 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

Programming / 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.
Programming / Re: I Want A Skilled Developer To Join Me On A Project! by fleshbone(m): 8:35am On May 20, 2017
king37:
Am a Master in any thing that deal with HTML & CSS, PHP, Java script, Xml, python ,Ruby, Tomcat,Xammp and wamp server, coding, Programming, App building including Android App and Apple ios, Social Network website like pinterest, Woo commerce like Amazon, Bulk Sms Website, Music and video Blog like YouTube, and the like, I will sucessfully handle all that kind of work. WhatsApp 0-9-0-3-3-1-0-4-1-3-4 to get your Work done


With all due respect, I hate to say this. But you can lie my guy.

8 Likes

Celebrities / Re: Moji Olaiya's Last Post On Instagram Before Her Death (Photos) by fleshbone(m): 9:55am On May 18, 2017
RIJF

1 Like

Programming / Re: Please Help, Browsers Can't Find My External Css by fleshbone(m): 8:55pm On May 15, 2017
Like the above Poster said, clear the cache!
Also make sure the link to the css file is in this
'http://the-css-link'. Best of luck
Programming / Re: My Python Guessing Game... Pythonistas Please Come In by fleshbone(m): 12:08pm On May 15, 2017
phililp:
is it the weed i took last week that is still disturbing me or the fish brain section of my brain just climaxed..

lol! thanks bro..

but how come i cudint figure awt somthing as this so soon.... anyway thanks once again.... u just got me a certificate of GO AHEAD..

once again thanks to all of ya... i have also learnt more things from each comments...




Lols! U're always welcome. Am glad I was useful.
Programming / Re: My Python Guessing Game... Pythonistas Please Come In by fleshbone(m): 12:19pm On May 14, 2017
phililp:



i have sir.. i think maybe u dont seem to understand the question...

this is it....

each key in the dictionary is the name of the fruit...and the value of the key is the description of the fruit..so now..

item_describtion = random.choice(my_dict.values())... #this will return a random value(description of any randomly selected fruit)

print (item_description) #prints the returned value/description and not the key..

then now in the while loop...

we wana check to see if the user's input is same as the key of that printed value/description

so if u say... if user_input == item description: # this is wrong because it will rather check to see if user's input is == item_description# which was = a random selected value and not key.... but our aim is to check if the user's input is the key to the printed value...

so i dont know how to implement this.. i tried using if user_input == item_describtion.key()# but this will give an attribut error cos key is not an attribute of a dictionary ... but keys() is.. which implies the whole keys in that dictionary..

but if we again say:
if user_input in my_dict : # this will run well but cause a (the hell do you call that error again..) .. yas!! SEMANTIC ERROR.. because say the description of apple was printed and the user inputs mango .... it will accept as tru cos mango is in my_dict.

hope understand ... so now thats my pain in the butt..

how to check if the user's input is == the key of that very printed description.. .. thanks to the house

BTW.. am enjoying this thread.



Hahahahahaha. Calm down bro!



Yes.! Key is kind of the name and value the data associated to key.


In PHP the dict() is called an associative array.

The easiest way out as for me, is to get the random key once.

Say

'Key = random.choice(my_dictionary.keys())'

This ('Key') we understand would hold a random key from the dictionary.

If you agree with the above, then to display the description associated with this Key

'Value = my_dictionary[str(Key)]'

Note: Very important you convert the key to a string

where Key is the random key we initialized above.


Print (Value)

'User_input = input()'

If you get some error with above then use

'User_input = raw_input()'


For the test,

'If user_input == Key:'


I seriously my explaination is good enough

I'll be waiting Phililp
Programming / Re: My Python Guessing Game... Pythonistas Please Come In by fleshbone(m): 1:48pm On May 13, 2017
phililp:



thanks sir... but this wont produce the required result..
because ..
item_description = random.choice(my_dict.key())
so if you print item_description the output would be a random selected key... not its value

dunno what the sleep does though..


Oh agreed!

That's why after the sleep (to cause a delay in seconds) The print(my_dict[item_description]) come to display the value of the random key.

Study the codes carefully again bro Phililp
Programming / Re: My Python Guessing Game... Pythonistas Please Come In by fleshbone(m): 11:57pm On May 12, 2017
silento is right bro!!!

Here's what i did with my 2.7 though and it worked perfectly. go through it and i hope you get the best out of it.

import random
from time import time,sleep

my_dict = dict()

my_dict['mango'] = '''green when unripe and yellow when riped..
has one seed. hipogeal type seed germination'''

my_dict['apple'] = '''Look kinda speriacl... has many seeds.
looks green when unripe; some looks red some yellow some still green'''

print('I will describe the fruit and you will say its name')

item_description = random.choice(my_dict.keys())

sleep(1)

print(my_dict[item_description])

chances = 5

my_guess =''

while True:
---if chances != 0:

------print('Enter your Guess')
------user_guess = (raw_input())

------if user_guess == item_description:

---------print ('correct! you only used', 6 - chances, 'chance')

---------break

------else:
---------chances -= 1

---------print ('Sorry, try again. You have', chances, 'chances left')
---else:
------print('Sorry, you\'ve run out of chances to guess. yor have', 0, 'guesses left')

------break

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


best of luck phililp boss


meanwhile, dont forget that when you have a chance left, it should be "1 chances left".
Programming / Re: Already Exist Dont Display 3000 k naira for who can solve it by fleshbone(m): 4:13pm On May 04, 2017
skyhighweb:
am not using pdo


What are yoU using.
Programming / Re: Already Exist Dont Display 3000 k naira for who can solve it by fleshbone(m): 3:34pm On May 04, 2017
Its sad I couldn't help. I have no idea about PDO.
Programming / Re: Already Exist Dont Display 3000 k naira for who can solve it by fleshbone(m): 4:59pm On May 03, 2017
skyhighweb:


hi ok i implemented where buyer != tagged, but it isnt working right it only works if the number are on the same roll eg

wont work like this

buyer tagged

4 5

2 0

6 4

the 4 above appears like that in the column need the code to check both columns not minding where the data is in the row

but works like this i altered it just to check and it works but not the way it should(works cause i put 4 in the same roll

buyer tagged

4 4

2 0

6 5




Then there must be a problem with ur foreach statement.


Check the foreach statement again.


Fetch the buyer into an associative_array, and tagged into another.

Try using this method (in_array()) in the code.

Foreach (buyer as buyer_value){

If ( in_array(buyer_value, tagged)){
Echo buyer_value.' In tagged';
}

Else{
Echo 'no buyer element in tagged'

}

}


This should work.

Please study carefully and apply. Thanks
Programming / Re: Already Exist Dont Display 3000 k naira for who can solve it by fleshbone(m): 4:13pm On May 03, 2017
skyhighweb:


hi sorry for bugging u and i tried the above didnt getting any output i guess am doing something wrong, heres the code am using
heres the ccomplete code

$query = "SELECT b.auction, b.buyer, b.bid, b.tagged, u.nick, u.rate_sum FROM " . $DBPrefix . "bids b

LEFT JOIN " . $DBPrefix . "users u ON (u.id = b.bidder) WHERE b.auction = :auc_id

ORDER BY b.bid asc, b.quantity DESC, b.willwin asc"; $params = array(); $params[] = array(':auc_id', $id, 'int');

$i = 0;
$hbidder_data = array();
foreach ($db->fetchall() as $bidrec)
{
if (!isset($bidderarray[$bidrec['nick']]))
{
if ($system->SETTINGS['buyerprivacy'] == 'y' && (!$user->logged_in || ($user->user_data['id'] != $auction_data['user'] && $user->user_data['id'] != $bidrec['bidder'])))
{
$bidderarray[$bidrec['nick']] = $bidrec['nick'];
$bidderarraynum++;
}

}

$template->assign_block_vars('tag_bidder', array(
'BGCOLOUR' => (!($i % 2)) ? '' : 'class="alt-row"',
'NAME' => $bidderarray[$bidrec['nick']],
'ID' => $bidderarray[$bidrec['id']]

));
$i++;
}


that display users name but when they show up in both columns (buyer and tagged) i dont want them to show up on the list, so u like comparing two columns in a table. thanks



Am not good with object oriented aspect of mysqli.

Am sorry I don't understand some few syntax above!
Programming / Re: Already Exist Dont Display 3000 k naira for who can solve it by fleshbone(m): 2:49pm On May 03, 2017
skyhighweb:
hi thanks for the effort but am talking more of columns here not two tables but too columns

The code should be shorter then:


$select_statement = "select * from table_name";
$result_statement = mysqli_query($db_connection,
$select_statement);
If(mysqli_num_rows($result_statement) > 0){
$column1 = mysqli_fetch_assoc($result_statement['column_name1']);

$column2 = mysqli_fetch_assoc($result_statement['column_name2']);



}
Else{
Echo "Zero Rows in table1"
}





Foreach ($column1 as $data_held){
If in_array($data_held, $column2){
Echo 'yes' //this will echo yes each time it encounter any.
}
Else{
Echo 'No' // for each that wasn't found.
}
}








Try this then.
Programming / Re: Already Exist Dont Display 3000 k naira for who can solve it by fleshbone(m): 1:28pm On May 03, 2017
skyhighweb:
plz how do i go about that?
Its being a while I did php/mysqli.
Assuming u hav ur db connection setup already!

$select_statement = "select * from table_name"; $result_statement = mysqli_query($db_connection, $select_statement);
If(mysqli_num_rows($result_statement) > 0){
$all_table = mysqli_fetch_assoc($result_statement);

}
Else{ Echo "Zero Rows in table1"
}

$select_statement2 = "select * from table_name2"; $result_statement2 = mysqli_query($db_connection, $select_statement2);
If(mysqli_num_rows($result_statement2) > 0){
$all_table2 = mysqli_fetch_assoc($result_statement2);

}
Else{ Echo "Zero Rows in table2"
}

Foreach ($all_table1['column_name'] as $data_held){
If in_array($data_held, $all_table2['column_name']){ Echo 'yes' //this will echo yes each time it encounter any. } Else{ Echo 'No' // for each that wasn't found. }
}




Try this, I hope it helps, I haven't tried it though.
Programming / Re: Already Exist Dont Display 3000 k naira for who can solve it by fleshbone(m): 11:36am On May 03, 2017
Fetch both table as an associative array. Then use:

For each element in array 1;
Use in_array() to check if it appears in array2




Goodluck skyhighweb.
Programming / Re: I Want To Learn Programming On My Own, Where Do I Start? by fleshbone(m): 7:23pm On May 02, 2017
Python is quite easy and its Object Oriented Programming.


The language with the easiest syntax I've seen is SQL.

Try it as well, though its database related.
Programming / Re: I Want To Learn Programming On My Own, Where Do I Start? by fleshbone(m): 7:23pm On May 02, 2017
Python is quite easy and its Object Oriented Programming.


The language with the easiest syntax I've seen is SQL.

Try it as well, though its database related.
Programming / Re: I Want To Learn Programming On My Own, Where Do I Start? by fleshbone(m): 7:21pm On May 02, 2017
Python is quite easy and its Object Oriented Programming.


The language with the easiest syntax I've seen is SQL.

Try it as well, though its database related.

(1) (2) (3) (4) (5) (of 5 pages)

(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. 70
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.