Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,152,749 members, 7,817,073 topics. Date: Saturday, 04 May 2024 at 03:13 AM

Gbolly1151's Posts

Nairaland Forum / Gbolly1151's Profile / Gbolly1151's Posts

(1) (2) (3) (4) (5) (6) (7) (8) (9) (10) (of 16 pages)

Programming / Re: AI Gurus And Data Scientists,please Help Me On This Question by gbolly1151(m): 7:40am On Jun 19, 2020
jesmond3945:
yes. For lattice public key encryption you can use a Monte Carlo simulation to get the basis which makes up the key together with machine learning which processes the basis.
For RSA and Elliptic curve, you can use Short or Grover's search
For Code public key you can prange's ISD but I proposed using Maximum likelihood reinforced with copula distribution.
Meh..then cryptography is not secured anymore since it can be hacked using ML because one feature of publickey encryption scheme is should not be able to derive public key from private key by any mean
Programming / Re: Common good python programming practices you should know by gbolly1151(m): 7:35am On Jun 19, 2020
iCode2:
Hmmmm you've so grabbed Python concept. I hope to be like you when I grow up.
It is not about the language, it is about data structure and algorithm sir
Programming / Re: Common good python programming practices you should know by gbolly1151(m): 9:59pm On Jun 18, 2020
iCode2:
Oh I just checked again now. I misunderstood the question. I was working on returning an item in the list as a string separated by comma with an and before the last item. Something like... Returning the first index as 'a, p, p, l, e, and s'.

Will that work?
Dont mind my naming

spam = ['apples', 'bananas', 'tofu', 'cats']

def printlist(List):
last=List.pop()
last=' and '+last
List.append(last)
return ','.join(List)

def wordlist(List):
for word in List:
print(printlist(list(word)))


wordlist(spam)
Programming / Re: Common good python programming practices you should know by gbolly1151(m): 9:44pm On Jun 18, 2020
iCode2:
Oh I just checked again now. I misunderstood the question. I was working on returning an item in the list as a string separated by comma with an and before the last item. Something like... Returning the first index as 'a, p, p, l, e, and s'.

Will that work?
Sure it will work
Programming / Re: AI Gurus And Data Scientists,please Help Me On This Question by gbolly1151(m): 5:39pm On Jun 18, 2020
peterangelo:


Yeah 100%✓
really? Then cryptography is not secured anymore
Programming / Re: AI Gurus And Data Scientists,please Help Me On This Question by gbolly1151(m): 4:30pm On Jun 18, 2020
peterangelo:

I can't wrap my head around your quiz.

Try to elaborate
Can statistical model be use to obtain private key from public key
Programming / AI Gurus And Data Scientists,please Help Me On This Question by gbolly1151(m): 3:10pm On Jun 18, 2020
It is possible to train a model to predict the hash function from a text?

And it is also possible to predict private key from public key in publickey encryption scheme?
Programming / Re: Common good python programming practices you should know by gbolly1151(m): 12:00pm On Jun 18, 2020
Grandlord:
Bad guy cool
Lolz...boss.
Programming / Re: Common good python programming practices you should know by gbolly1151(m): 10:19am On Jun 18, 2020
If you want a variable or method that should be called;
1) from anywhere outside of a class,then declare the variable/method as public e.g in python name='gbolly'

2) within a class only,then declare the variable/method as private e.g in python __name='gbolly' #double underscore

3) only from class and subclasses then declare it protected
e.g in python _name='gbolly' #single underscore
Programming / Re: Common good python programming practices you should know by gbolly1151(m): 10:19am On Jun 18, 2020
CuteNerdyDude:
Thanks man. �
you are welcome bro
Programming / Re: Common good python programming practices you should know by gbolly1151(m): 3:30am On Jun 18, 2020
iCode2:
spam = ['apples', 'bananas', 'tofu', 'cats']

Write a function that takes a list value as an argument and returns a string with all the items separated by a comma and a space, with and inserted before the last item. For example, passing the previous spam list to the function would return 'apples, bananas, tofu, and cats'. But your function should be able to work with any list value passed to it.
Just seeing this


spam = ['apples', 'bananas', 'tofu', 'cats']

def printlist(List):
last=List.pop()
last=' and '+last
List.append(last)
return ','.join(List)

print(printlist(spam))

1 Like

Programming / Re: Common good python programming practices you should know by gbolly1151(m): 3:11am On Jun 18, 2020
CuteNerdyDude:
@gbolly1151 please what materials would you recommend for an intermediate python programmer?.
realpython.com

1 Like

Programming / Re: Common good python programming practices you should know by gbolly1151(m): 7:40pm On Jun 16, 2020
In need of a special data type(object)?....you create class,

In need of special class?....you create meta class
Politics / Re: Oyo Relaxes Curfew, Gives Updates On Resumption Of Schools, Offices, Churches by gbolly1151(m): 12:59pm On Jun 16, 2020
Resume school! Resume school!! It is because you haven't lost someone in this covid struggle? Please let be guided ooo covid is real.....what we should voice out is to redesign the system,then we will be safe.

1 Like

Politics / Re: Oyo Relaxes Curfew, Gives Updates On Resumption Of Schools, Offices, Churches by gbolly1151(m): 12:54pm On Jun 16, 2020
jidamsel43:
good development

Malaria kills more than 20000 Nigerians every month . Covid-19 killed 400 Nigerians in three months.

Government order lockdown because of Covid-19 to the extend that Nigerians lost many souls because of lockdown.

Nigerian government has not direct policy to eradicate Malaria in the country despite the highest fatality rate .

The cause of Malaria is MOSQUITOES which can be eradicated with provision of clean and serene environment coupled with constant fumigation of environment.

Government has abandoned the fight against
Malaria because it is not sensational while the battle against convid-19 continue everyday with billions of naira down the drain .

Covid-19 fatalities are recorded among the elite while malaria kills in poverty ridden environment.

Covid-19 is not a threat in Nigeria .

Our government is our biggest threat .

covid is a contact disease malaria is not...so how do they correlate?
Programming / Re: Python For Accountants by gbolly1151(m): 5:15pm On Jun 15, 2020
SKYQUEST:


I agree with you on read_csv ( ); kindly run the function on the file (it is still in the attachment above) and lets have your dataFrame output.
I dont get you sir...this is xlsx extension, you cant expect read_csv to open it or maybe i dont understand what you are requesting for
Programming / Re: Python For Accountants by gbolly1151(m): 2:12pm On Jun 12, 2020
SKYQUEST:
If you try to read the file with the read_csv( ) function, an error will be thrown because the file is not a comma seperated values (csv) file.

I disagree with you sir,that because the file is not a comma seperated value.

The class read_csv(filename,delimiter=' ') will open file separated by space character.
Programming / Re: Python 3: Exercises And Solutions. by gbolly1151(m): 12:02am On Jun 12, 2020
iCode2:
Wow it worked! Thanks man. I didn't know about that capitalise method. You're good man.
There is a bug that i fix just now,i remove initial (.) From the sentence to avoid two (.)
Programming / Re: Python 3: Exercises And Solutions. by gbolly1151(m): 11:43pm On Jun 11, 2020
iCode2:
Write a program that asks the user to enter a sentence and then randomly rearranges the words of the sentence. Make sure that the sentence that will be printed out starts with a capital, that the original first word is not capitalised if it comes in the middle of the sentence, and that the period is in the right place.


sentence=str(input('your sentence: ')).replace('.','').split()
random.shuffle(sentence)
print(" ".join(sentence).capitalize(),end='.')


please check
Programming / Re: Python 3: Exercises And Solutions. by gbolly1151(m): 7:06pm On Jun 11, 2020
Question to check your data structure and algorithm skill

When a share of common stock of some company is sold, the capital gain (or, sometimes, loss) is the difference between the share’s selling price and the price originally paid to buy it. This rule is easy to understand for a single share, but if we sell multiple shares of stock bought over a long period of time, then we must identify the shares actually being sold. A standard accounting principle for identifying which shares of a stock were sold in such a case is to use a FIFO protocol—the shares sold are the ones that have been held the longest (indeed, this is the default method built into several personal finance software packages). For example, suppose we buy 100 shares at $20 each on day 1, 20 shares at $24 on day 2, 200 shares at $36 on day 3, and then sell 150 shares on day 4 at $30 each. Then applying the FIFO protocol means that of the 150 shares sold, 100 were bought on day 1, 20 were bought on day 2, and 30 were bought on day 3. The capital gain in this case would therefore be 100·10+20·6+30·(−6), or $940. Write a program that takes as input a sequence of transactions of the form “buy x share(s) at $y each” or “sell x share(s) at $y each,” assuming that the transactions occur on consecutive days and the values x and y are integers. Given this input sequence, the output should be the total capital gain (or loss) for the entire sequence, using the FIFO protocol to identify shares.
Programming / Re: Python 3: Exercises And Solutions. by gbolly1151(m): 7:02pm On Jun 11, 2020
iCode2:
Write a program that asks the user to enter a sentence and then randomly rearranges the words of the sentence. Make sure that the sentence that will be printed out starts with a capital, that the original first word is not capitalised if it comes in the middle of the sentence, and that the period is in the right place.
Can you cite example out input and output?
Programming / Re: Common good python programming practices you should know by gbolly1151(m): 12:41pm On Jun 11, 2020

'''
what is @property?
@property is a decorator and what is a decorator?

Decorator is a technique used to change the behavior of
an object.

@property is a decorator used to change the behaviour
of a class method,it is use mostly to enable a
class method to behave as an attribute.

Now let illustrate attribute call
'''
class Test:
def __init__(self,var1,var2):
self.var1=var1
self.var2=var2

T1 = Test(2,3)
print('initial var1',T1.var1) #output: initial var1 2
print('initial var2',T1.var2) #output: initial var2 3
#changing the value of var1 and var2
T1.var1=6
T1.var2=10
print('new var1',T1.var1) #output: new var1 6
print('new var2',T1.var2) #output: new var2 10


'''
T1.var1 and T1.var2 are attribute calls

Now let see how method behave when we call it like an attribute
'''
class Test1:
def __init__(self):
self._var3=0

#@property
def var3(self):
return self._var3

#@var3.setter
def var3(self,value):
self._var3=value
T2= Test1()
'''
if you comment @property and then calling T2.var3 will return something like
<bound methoud T1.var3.....>
that is the name given to the function by interpreter
'''
print(T2.var3) #output: <bound methoud T1.var3.....>

'''
with the help of @property we can change how class method will behave
when it is called like an attribute.
in our case, we want the method to return a value and not object name
when it is called like an attribute

now uncomment the @property and @var3.setter
'''

print('initial var3',T2.var3) #output: initial var3 0
#setting new value for _var3
T2.var3 = 4
print('new var3',T2.var3) #output: new var3 4

1 Like 1 Share

Programming / Re: Python 3: Exercises And Solutions. by gbolly1151(m): 3:55am On Jun 10, 2020
Shepherdd:


Although this question does not provide the routing table I made some assumptions.

routing_table = {
'a': {'c': 5, 'b': 1},
'b': {'a': 1, 'd': 4, 'c': 2},
'c': {'e': 3, 'b': 2, 'd': 2},
'd': {'b': 4, 'c': 2, 'e': 8, 'g': 1},
'e': {'c': 3, 'f': 2, 'd': 8, 'g': 1},
'f': {'e': 2, 'g': 1},
'g': {'d': 1, 'e': 1, 'f': 1},
}

def grade_route (vertex, links, total_cost, previous):
for destination, cost in links.items():
previous_cost = total_cost[destination]
potential_cost = cost + total_cost[vertex]

if potential_cost < previous_cost:
total_cost[destination] = potential_cost
previous[destination] = vertex

def shortest_path(graph, source, destination):
previous = {}
total_cost = {vertex: (lambda x : float('inf') if x != source else 0)(vertex) for vertex in graph.keys()}
route = [destination]

for vertex, links in graph.items():
grade_route (vertex, links, total_cost, previous)

trace = destination
while True:
pth = previous[trace]
route.append(pth)
trace = pth
if pth == source:
return [total_cost[destination], route[::-1]]

print(shortest_path(routing_table , 'a', 'c'))
### ===> [3, ['a', 'b', 'c']]


Although their might be multiple route to a destination I avoided implementing this for brevity. DS & Algo questions sometimes aren't easy!!!
You have done a great job here bro....graph and tree questions aren't friendly
Programming / Re: Common good python programming practices you should know by gbolly1151(m): 9:15pm On Jun 09, 2020
Predstan:


Learning different data structures actually. I wrote one that uses List but still quadratic. Because using nested list, I have to iterate over each list of the both Matrices.
One advantage of using the Array or the LinkedList is the memory since List creates double of storage being used.

What I read tho.
Zip two list should reduce it,just thinking
Programming / Re: Common good python programming practices you should know by gbolly1151(m): 8:49pm On Jun 09, 2020
Predstan:


Learning different data structures actually. I wrote one that uses List but still quadratic. Because using nested list, I have to iterate over each list of the both Matrices.
One advantage of using the Array or the LinkedList is the memory since List creates double of storage being used.

What I read tho.

Hmm....ok
Programming / Re: Common good python programming practices you should know by gbolly1151(m): 5:57pm On Jun 09, 2020
Predstan:



I finally used LinkedList for the SparseMatrix and it was just Literarilly better. From Quartic to Quadratic

https://github.com/Predstan/Algorithm-and-Data-Structure/blob/master/ch6/SparseMatrix%20Using%20Sorted%20Linkedlist/sparseMatrix.py
But still curious why you dont want to use list

Access time O(1)
Programming / Re: Common good python programming practices you should know by gbolly1151(m): 8:58am On Jun 07, 2020
Should:
OK, God bless...
Amen
Programming / Re: LEARN ETHICAL HACKING,TIPS AND TRICKS by gbolly1151(m): 11:40pm On Jun 06, 2020
nurain150:
LINUX COMMAND LINE ..
Let simplfy:
1.what a directory means.
2.piping and redirect
3.learning a new tool and real command line walkaround.
...
WHAT A DIRECTORY MEANS
A directory is a folder.the same folder in windows.that what it means.on cmd windows it usually represented with \\\ and in Linux it ///...cool one so Linux is our main focus.say am nurain.as my username .on Linux arch my user folder is HOME on windows it USERS.
So for example if you login in your terminal you default working directory will be nurain .I talk by example say my terminal now is nurain so my current working directiory will be / nurain.so the mount is root.so /root/home/nurain is my folder using an absolute path .but a relative path is /nurain.In this tutorial I will be using ls as a command exaample command to be denoted by **.....so say *ls /root/home/nurain* will be the same thing as saying *ls* in the nurain folder.you gat me example.
Say my folder contains
a.txt b.php.
Then calling ls from nurain directory will list does .while calling ls with /root.....
Willl do the samw thing Shay u gat.....Comment ooo ..ask questions ...let know you are following ..thanks abeg let me behave like those author ....20 likes and 10 comment to unlock the next chapter.a
Ride on
Programming / Re: Common good python programming practices you should know by gbolly1151(m): 11:32pm On Jun 06, 2020
Should:

The below screenshot confused every me, while trying to understand Identity function..
Everything was going smoothly, until those figures appeared below "id(x), id(y)" ..
how they got the value on red...
The value in red are the memory addresses where x and y are stored,these values differs with PC. It is your pc that is responsible for how values are stored in the memory, id() only return the memory address
Programming / Re: Common good python programming practices you should know by gbolly1151(m): 9:56pm On Jun 06, 2020
Predstan:


I used the Binary search to insert an element into the right position in the list. So the 0(.) Is just Logn. Instead of returning true or false, it returns the position of an item after divide and conquer, then I use the insert function to insert in the right position in the list.

I also wrote a game called Game of Life where organisms dies or lives with respect to the number of organisms around them that are alive. Its similar code, you may check it here Boss.

Thanks

https://github.com/Predstan/Algorithm-and-Data-Structure/tree/master/ch5/Game%20Of%20Life%20-%20Improved

The first file is the text based implementation of the game, the second is the LifeGrid Class where I used the list and Divide and conquer


Will check it out bro
Programming / Re: Common good python programming practices you should know by gbolly1151(m): 7:57pm On Jun 06, 2020
What are factory functions?
These are functions that return inner function

def myprint():
return print
customized_print=myprint()
customized_print('hello word')

Output: hello world

#let use some print argument on our customized_print

customized_print('hello worl',end='.')


This is the basic of decorator in python
Programming / Re: LEARN ETHICAL HACKING,TIPS AND TRICKS by gbolly1151(m): 6:32pm On Jun 06, 2020
@Should i think this thread will help

1 Like

(1) (2) (3) (4) (5) (6) (7) (8) (9) (10) (of 16 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. 51
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.