Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,151,129 members, 7,811,193 topics. Date: Sunday, 28 April 2024 at 05:49 AM

Stealthtiger's Posts

Nairaland Forum / Stealthtiger's Profile / Stealthtiger's Posts

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

Romance / Re: Ladies Come In Here And See This ( Image ) by stealthtiger(m): 1:57pm On May 15, 2017
Smellymouth:


Hahahhah.wait lemme grab my whistle.. cheesy
I can be your surrogate whistle blower tongue
Travel / Re: FG To Merge Arik, Aero As National Carrier by stealthtiger(m): 10:35am On May 15, 2017
Would it still the same people that managed the defunct Nigeria airways that would also mange this one.

They also have to be independent. They should be free of any sort of interference in their operations especially from the senators and other individuals that contributed to the failure of the former

8 Likes 3 Shares

Sports / Re: Anthony Joshua Shares Photos Of His Son by stealthtiger(m): 10:23am On May 15, 2017
Oya sharp sharp. Ti omode yi ba ti pe odun marun lo enroll omo si Arsenal FC academy. A gbodo se ika fun omo Mourinho yen o. So gbo Oro mi sha.
Programming / Re: Learn Python- Introduction To Programming by stealthtiger(m): 4:51pm On May 14, 2017
NB: I'm also a learner in Python so all criticisms are welcome.At least it should be fair minded, objective and be borne out of a heart that seeks to make positive changes.

So if you see me asking questions in Python don't be amused because I'm also learning.

2 Likes

Programming / Re: Learn Python- Introduction To Programming by stealthtiger(m): 4:50pm On May 14, 2017
.
Programming / Re: Learn Python- Introduction To Programming by stealthtiger(m): 4:44pm On May 14, 2017
4. Loops
When you try to perform a task more than once, Python has the capability of handling that task.
For example of you were to open about 10 files, then do some thing to them , then close. It would be easy for you to perform the task without a loop. But of you were given 100 000 files , now this would take you about 10 years to do it manually. So computers are very capable of performing a task severally and Python has that ability.

The first loop we'd be talking about is the WHILE LOOP.

We basically perform repetitions using loops.
In programming context it's called ITERATION.
That is to say line one does something, then it goes to line 2, line 2 them says the program shouldn't terminate then it returns to line1 again and performs that task.
So that circuit of movement is called an ITERATION.

Let's get to coding

count = 0
While count <=4:
print(count)
count += 1

0
1
2
3
4

Explanation of the above code
To use a while loop you have to initialize a counter. We intialized our counter to 0 so our loops would start from 0.
Our counter is count.
The counter also acts as an accumulator.
As the program makes on iteration 1 is added to count, which then stores it.
On the second iteration another 1 is added to account until it makes 5 iterations. So count also gets updated after an iteration.

Beware: when using a while loop always make sure the loop terminates unless it would keep on running till it overflows the stack.
This kind of loop is called an infinite loop. For example

i = 0
While i == 0:
print("infinite loop. This loop would continue to run" )

This loop would run without stopping because there's no condition that terminates this program.


def sequence (n):
while n != 1:
print(n)
if n % 2 == 0:
n = n/2
else:
n = n*3+1

Explanation:
We created a function called sequence with a ln argument n.

Until the value n is equal to 1 before it terminates. Since we said while n is not equal to one.
So if it's contrary it should stop.
If the n is even it is divided by 2 if it's false it is replaced by n*3+1.
If you pass 10 to the argument n the result would be: 3, 10, 5, 16, 8, 4, 2, 1.
When it gets to one the loop terminates.

But there's something really interesting and fascinating about this loop.
Actually there are 2 things that are interesting but the second is more.
1. This is an indefinite loop but it doesn't overflow the stack. The computation keeps on occuring until the condition is met.
There's no even any obvious proof that any would reach 1.
The number of iterations are unknown to us but we know it would terminate due to the expressions in the if and else statements.

2. It's impossible to prove that this program terminates for all positive values of n.
No one has been able to prove this.

You can go read about the collatz conjecture.

This code was gotten from Allen Downey's think Python textbook. A recommended one for you all.

2 Likes

Programming / Re: Learn Python- Introduction To Programming by stealthtiger(m): 4:43pm On May 14, 2017
.
Programming / Re: Learn Python- Introduction To Programming by stealthtiger(m): 4:42pm On May 14, 2017
.
Programming / Re: Learn Python- Introduction To Programming by stealthtiger(m): 3:36pm On May 14, 2017
phililp:
pls someone help... whats the difference between mutable and immutable in python..


a detailed explanation will be highly appreciated

thanks
Immutable: the value stored in a variable can't be changed.
Mutable: the value stored in the variable can be changed.

Strings, dictionaries, tuples are immutable.
Lists are mutable.

We'd talk about them explicitly as we progress

1 Like

Education / Re: Under-30 Nigerian Lady Bags A Ph.d In Nuclear Physics (photos) by stealthtiger(m): 8:35pm On May 11, 2017
Shortyy:
What's her name plizzz? grin
Andrea Macaulay
Travel / Re: The Golden Tulip Hotel In Anambra: 12 Facts by stealthtiger(m): 12:40pm On May 10, 2017
Anambra the safest state?
I beg to differ

1 Like

Politics / Re: Osinbanjo And Yorubas Should Handle The Snakes Alone. by stealthtiger(m): 12:23pm On May 10, 2017
Why is there so much hate?
Programming / Re: Python Creatives: Where Were We? by stealthtiger(m): 11:14am On May 09, 2017
Nairaland / General / Re: 7 Types Of Lies People Tell by stealthtiger(m): 11:08am On May 09, 2017
Oloruntobiflink:
Add alternative fact too
Kellyanne Conway
Donald Trump was the first person to use the word in his book.
So what does that make him?
Nairaland / General / Re: 7 Types Of Lies People Tell by stealthtiger(m): 11:07am On May 09, 2017
Which Lie is Lie guilty of?
Lol grin
Nairaland / General / Re: Civet That Was Killed In My Cousin's Compound by stealthtiger(m): 11:01am On May 09, 2017
Atmmachine:

This is an African civet

We call it Edi Abani in igbo

Don't feel sorry for that idiot, they're about 100 million in igboland and they steal people's livestocks

Good for the bastard, his brothers and sisters will learn some lesson and stop stealing
Your signature is disturbing
Programming / Re: Learn Python- Introduction To Programming by stealthtiger(m): 10:55am On May 09, 2017
CONTINUATION OF FUNCTIONS.
The x is an argument which is used as a variable.


def product (x, y)
print(x*y)

product(8, 3)


By the time you run this program, 24 would be printed on screen.
Let me explain how it works:

firstly, we defined the function using the def keyword. We named the function as product.

The function contains to Arguments that would be assigned values.

The second line multiplies the 2 arguments and prints it.

But for it to get printed we have to call the function.
Also we have to assign the values to the variables in the function when calling it. This was done on the 4th line.

You can also call another function within a function
Eg.


def states():
print('Lagos')
print('Ogun')
def states_again():
states()
states()

states_again()

Lagos
Ogun
Lagos
Ogun

So we defined a function called statesand told it to do something. Which is to print Lagos and Ogun.
We also defined another function called states_again containing the first function twice.

So when we called the second function, Python immediately read what was in the second function and discovered it's also a function. Python looks for where that function was defined and read the indented code. Which it to print it twice.

This is called flow of execution.
You don't have to read a code in a top-down manner. You might get confused. A part at the top might link to another part at the bottom and another part somewhere making it difficult to understand.

What you then do is to follow the flow of execution. How one parts calls another. Find the coherence in the code. Immerse yourself and you'd see how it moves.

MATH FUNCTIONS
There's a module in Python called math. This module object provides us with mathematical functions.

You have to import the module before it can be used.

>>> import math

This imports the module object called math.
To make use of the module you have to specify the module followed by a dot and by the function you want to make use of. This is called the dot notation Eg let's find the square root of 16

>>> import math
>>>math.sqrt(16)
4

We import the module first, then a dot followed by the function and our value as argument in a parentheses.
So these functions we've seen are in-built functions. You don't have to write a code to fine the sqrt of a number or logarithm of a number. You can just use their functions on the fly.


RETURN VALUES: in Python you can also return values. Any code after the return statement​ is called dead code, because it never executes.
A return statement can't be used outside a function.


def product (x, y):
if x*y >=2:
print ('product of x, y is greater than 2')
return x
else:
return y

print(product (5, 4))

Product of x, y is greater than 2
5

We told Python that if the product of x,y is greater than 2 it should print the above and return x to the product, else it should do the contrary.
Programming / Re: A Call To Nigerian Programmers by stealthtiger(m): 9:27pm On May 07, 2017
Oh! I see.

We're not just getting our priorities right. Untill we retrace are foot steps and look at what we're overlooking.
It's just a ground up process
Programming / Re: A Call To Nigerian Programmers by stealthtiger(m): 7:54pm On May 07, 2017
Always online?
Programming / Re: A Call To Nigerian Programmers by stealthtiger(m): 7:47pm On May 07, 2017
I think we need to begin to solve the problems that are peculiar to our own demography, life style.

There are still underlying issues that need to be solved before we can start doing these so-called Bigg things folks over there do.

Take e-commerce as an example.
Some people argue that e-commerce isn't something Nigeria is ready for.

There are several contributing factors that determine the success of e-commerce like efficiency of internet payments and confidence in making payments online, security, internet infrastructure, logistics etc. These are serious problems that needs to be solved in these areas and e-commerce can't be successful as we intend without these contributing factors running well.

So if the fundamental problems can be solved in a way that's local to us, things would begin to take shape on their own.

2 Likes

Programming / Re: A Call To Nigerian Programmers by stealthtiger(m): 7:31pm On May 07, 2017
4dor:


This is another comment I really like. Unfortunately, you're like a Pastor preaching in a bar. Most of the people you're talking to have no idea.
grin
Lol.. but don't underestimate people o

1 Like

Programming / Re: Learn Python- Introduction To Programming by stealthtiger(m): 5:47pm On May 07, 2017
4. FUNCTIONS
Code reuse: A word that's common among programmers. What comes to your mind when you here about code reuse is Functions.
Just imagine you're writing a complex piece of program of about 4000lines. This is large to an extent at least to your level of programming.

Debugging this kind of program even among Senior developers can be a night mare.

But breaking this program into separate parts by encapsulating them in a function would make your life a whole lot easier.

So if the program does numerous things, like updating a server. You can write a code that does that an ld encapsulate it in a function. By the time you've written about 10 functions that makes the program do what you want it to do, then you can start wiring the functions together.
So it makes your life easier.

Back to code reuse. Imagine you're writing another program that computes the payroll of a company and sends it's to the employees mail.

If you've written a program before that computes the payroll of employees in another company and does something else to it. You can just take the function that computes the payroll and use it in your new programming job.
Viola!! You don't have to write any code that does it again because you've encapsulated that capability in a function in another program.
So using functions encourages code reuse

Let's do something.
To declare a function in Python we make use of the def keyword.

def pay_roll():

This kind of function has a zero argument.

Functions and Arguments:
We've seen variables above. But you can also have a variable in between the parentheses of the function
Eg

[color=#990000][
def pay_roll(x):
/color]
X acts as variable
Programming / Re: Learn Python- Introduction To Programming by stealthtiger(m): 5:26pm On May 07, 2017
CHAINED CONDITIONALS:
Sometimes you might have more than a possibility and we now need more branches.

For example:
We'd write a code that prints the age of students in a class of 4, when we input their first name.
If there's no such name the program NB prints out that there's no one with such name in the class.

The names are Bill, Zuck, Elon, Emma

NB: this code would be written in script mode and then interpreted by the Python IDLE. You can directly write it in the IDLE.


name = input('Enter name: ')
if name = 'Bill':
print('61')
elif name = 'Zuck':
print('32')
elif name = 'Elon':
print = ('45')
elif name = 'Emma':
print = ('19')
else:
('No such name')

When we run this code, Python interpreter tells us to enter a name. If we enter Bill the interpreter spits out 61. If we enter any other name that's part of the class, the interpreter spits the corresponding age.

So here, we're testing for more than one instance. Not just BILL, but for the remaining students.

And if the name we enter isn't part of the class, then the indented code in the else statement would be executed.

ELIF is the same as else if just like in Visual Basic programming language. Se was removed and concatenated with if.

Obviously I'm the youngest in that class. grin
A business class or something cool
Programming / Re: Learn Python- Introduction To Programming by stealthtiger(m): 2:25pm On May 07, 2017
4kings:
stealthtiger please continue na...

Meanwhile Seun, you've not answered me oo: can you disable the emoticons code when inside a code tag?
I'd continue the tutorial in no time.
Please forgive
Programming / Re: Why Are Most Nigerian Programmers Interested In Web Development? by stealthtiger(m): 9:16pm On May 06, 2017
IamaNigerianGuy:


I did far better than you who referred to Nigerian coders as 'lazy' (amongst other put-downs)
There's nothing wrong in having a constructive criticism.
It's something that should be embraced
Programming / Re: Why Are Most Nigerian Programmers Interested In Web Development? by stealthtiger(m): 6:50pm On May 06, 2017
IamaNigerianGuy:


You wont go far with your hasty generalizations.

1. Web development is where the action is right now all over the world and far into the foreseeable future.
2. Machine learning is done to meet a need. We have not yet reached that level.
3.Machine learning is expensive; Nigerians do not have spare cash. It costs non-trivial amounts of money to set up a decent cluster and when you do that where is the data-set to run? You require huge data sets to make valid conclusions. There is simply no data in most cases. When you gain the knowledge how do you monetize your knowledge?
4. Game development is expensive and is a thing for well funded teams. Nigerians do not play games enough for development to be commercially viable.
5. Embedded systems development is specific to industry. Do you see any industries commissioning developers in Nigeria ?

Stop running down your countrymen.
It has little to do with laziness and more attributable to market demand.
There are brilliant coders in Nigeria that will run rings round you and many google /fb/ engineers in tests of ability. https://news.ycombinator.com/item?id=14071540
The average American developer will struggle to survive much less produce any work under Nigerian conditions.
Finally, there are people doing ML in their private work-spaces. They just do not want to advertize. Ask the right questions and maybe they will respond. undecided
Thanks for your opinion.

But it can also be passed without you been uncessarily derogatory.

2 Likes 1 Share

Programming / Re: Learn Python- Introduction To Programming by stealthtiger(m): 6:45pm On May 06, 2017
ANTONINEUTRON:
@op U Can Use Ideone.com For Writing The Code
And Posting The Link Here


*suggestion*
Thanks
Programming / Re: An Online Compiler, Interpreter And IDE For Nairaland by stealthtiger(m): 6:43pm On May 06, 2017
dhtml18:
It is okay to insult me, but let me ask you one question - Did Seun ask for your advice? Or do you think it is cool to start running your mouth on another person's business? It is a free world - if you think you can build a better Nairaland, then you are welcome to try.

Because as far as I am concerned, this thread is just as if you are trying to rubbish Nairaland, if you do not like this board as it is - you are welcome to EXIT and NEVER COME BACK.

1. I don't know who's insulting who. Reflect on your post's to unveil your clouded lapses.

2. Everyone is entitled to he's or her opinion.

3. I don't know if you're reading my post backward.

I started this thread with a good intention. Which is to give an opinion. And I'm not forcing it down anyone's​ throat.
So how dare you tell me I'm rubbishing nairaland.
Has giving a honest opinion become ridiculing the recipient?

I don't know why some humans create problems from no where

What ever grievances you have with anyone please keep it to yourself rather than coming here to type thoughtless string of characters filled with impunity.

On your last paragraph: That should be a reflection of you.

PLEASE BE COURTEOUS WITH YOUR REMARKS.

1 Like

Education / Re: What Course Would You Study If You Had The Chance To Go Back To School And Why? by stealthtiger(m): 7:43am On May 05, 2017
Systems Engineering

2 Likes

Programming / Re: An Online Compiler, Interpreter And IDE For Nairaland by stealthtiger(m): 7:29am On May 05, 2017
dhtml18:


True, and you should understand that every forum has its primary purpose and theme. The structure of stackoverflow, quora and business model is different from that of Nairaland.
You should understand that running a business, and just setting up stuffs are 2 different things entirely. Nairaland has stayed true to its purpose, and that is why it has survived whereas a lot of more fanciful forums that sprung up over time have died for many many reasons, and many of them even had far more features before they died.

Some of you dudes believe that you know how to run a forum business better than Seun Osewa, but no, it is not that simple. Sitting down on your PC and imagining what you can do, and actually running and sustaining something are 2 different matters entirely.

Dont get me wrong, I am not criticizing your IDEA, neither am I saying that Nairaland cannot step up - but in my own opinion, adding stackoverflow features to nairaland cannot get it anywhere (I might be wrong mind you).

Lol.. this got me laughing hard.
Do you think you've found one?
Because​ you're getting this across to the wrong person
No need for this epistle of Paul

PS
This is a programming section and you know what it should entail.

I'm not forcing any idea down any ones throat.
Programming / Re: An Online Compiler, Interpreter And IDE For Nairaland by stealthtiger(m): 7:24am On May 05, 2017
dhtml18:


True, and you should understand that every forum has its primary purpose and theme. The structure of stackoverflow, quora and business model is different from that of Nairaland.
You should understand that running a business, and just setting up stuffs are 2 different things entirely. Nairaland has stayed true to its purpose, and that is why it has survived whereas a lot of more fanciful forums that sprung up over time have died for many many reasons, and many of them even had far more features before they died.

Some of you dudes believe that you know how to run a forum business better than Seun Osewa, but no, it is not that simple. Sitting down on your PC and imagining what you can do, and actually running and sustaining something are 2 different matters entirely.

Dont get me wrong, I am not criticizing your IDEA, neither am I saying that Nairaland cannot step up - but in my own opinion, adding stackoverflow features to nairaland cannot get it anywhere (I might be wrong mind you).

Lol.. this got me laughing hard.
Do you think you've found one?

This is a programming section and you know what it should entail.

I'm not forcing any idea down any ones throat.
Programming / Re: An Online Compiler, Interpreter And IDE For Nairaland by stealthtiger(m): 7:20am On May 05, 2017
X

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