Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,143,480 members, 7,781,407 topics. Date: Friday, 29 March 2024 at 01:58 PM

Gbolly1151's Posts

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

(1) (2) (3) (4) (5) (6) (7) (8) (9) (10) (11) (12) (13) (14) (of 16 pages)

Programming / Re: Common good python programming practices you should know by gbolly1151(m): 2:15am On Apr 18, 2020
For anyone interested in learning python from scratch you can pm me on 07060435624

hourly payment based,so you can quickly option out.
Programming / Re: Common good python programming practices you should know by gbolly1151(m): 2:04am On Apr 18, 2020
When you use return keyword,it actually return a value and STOP the function, therefore if you have two return keywords in a function only one will work based on the condition usually if/else statement. therefore avoid use of if/else statment this way

#avoid this
def isodd(num):
if num%2==1:
return True
else: return False

#use this
def isodd(num):
if num%2==1:
return True
return False


Programming / Re: Tutorial: Object Oriented Programming Paradigm For Beginners in Python by gbolly1151(m): 1:10pm On Apr 16, 2020
A lion is a species with a short,rounded head, a reduced neck,round ears, and a hairy tuft at the end of its tail. It has prominent mane,which is the most recognisable feature of the species. They can run,jump and do hunt prey.


Who is following?
Programming / Re: Tutorial: Object Oriented Programming Paradigm For Beginners in Python by gbolly1151(m): 10:19am On Apr 16, 2020
I will post some description and will like you guys to write the class structure in this way before will move to next topic in inheritance

Class:
Name -
Attributes -
Method -
Programming / Re: Tutorial: Object Oriented Programming Paradigm For Beginners in Python by gbolly1151(m): 9:51pm On Apr 14, 2020
koyla:
Thanks much for your effort
You are welcome sir
Programming / Re: Common good python programming practices you should know by gbolly1151(m): 7:38pm On Apr 14, 2020
I have started another thread,you can follow

Tutorial: Object Oriented Programming Paradigm For Beginners
Programming / Re: Tutorial: Object Oriented Programming Paradigm For Beginners in Python by gbolly1151(m): 7:26pm On Apr 14, 2020
koyla:
Following
Posted now
Programming / Re: Tutorial: Object Oriented Programming Paradigm For Beginners in Python by gbolly1151(m): 7:26pm On Apr 14, 2020
Now let me write description of a dog,this will be the basis from which we will learn OOP

DESCRIPTION OF A DOG
Dog is an Animal
It has 4 legs
It has 1 tail
It is fat
It can bark
It can bite
It can run


OOP is a programming paradigm that deal with object and class relationship... That statement look too complex to me so am going to break it down in a way we can quickly grab

What is an object?
Object is anything you can describe e.g the above is the description about Dog,therefore Dog is an object. Noun is an object i.e any name of animal,place or things... Lol i prefer that definition to naming words.other example of object are
man,woman,Hausa,pen,pencil, shoe

What is a class?
Class refer to the framework of an object or noun,in order word what object is made up, it composed of 3 part;

1.name - this is general name of object,that share 'am a', 'is a' or 'is an' relationship with an object
e.g1 man is a person,woman is a person. Person is the class name.
e.g2 Hausa is a tribe,Youruba is a tribe,Igbo is a tribe. Tribe is the class name
In the above description of a dog,we say Dog is an Animal. Animal is the class name

2.Attribute - this hold information about an object,that share 'is' or 'has' relationship with the value e.g it has 4 leg(information about leg),it is fat(information about body) . Look at those statement we can rewrite those as Dog legs is 4, Dog body is fat.
The attribute is legs and value is 4. I.e legs=4
The second attribute is body and value is fat i.e body ='fat'

3.method - this tell us about the ability of the object,what the object 'can' do or 'will' do,it is the function the object will perform in the system. From the description of a dog,its abilities are;
It can bark,it can bite,it can run

Method are bark(),bite(),run()

Now let us decrypt that description of Dog to form a class for object Dog


Object - Dog
Class;
name - Animal
Attribute - Legs,Tail,Body
Method - bark(),bite(),run()

Just snack to chop, write a description about yourself and write out the class name,attribute and method
Programming / Tutorial: Object Oriented Programming Paradigm For Beginners in Python by gbolly1151(m): 5:48pm On Apr 14, 2020
Hello Nairalands,this was demanded from my thread "common python programming practice". So in this thread,i will try as much as possible to make OOP understandable for anyone who want to learn it.

So stay tune as the tutorial will be coming
Health / Re: 20 New Cases Of Coronavirus In Nigeria. Total 343. 91 Discharged. 10 Deaths by gbolly1151(m): 10:21pm On Apr 13, 2020
Still wondering why our aboki got low count,am not sure they are investigating that region wella
Programming / Re: Common good python programming practices you should know by gbolly1151(m): 8:56pm On Apr 12, 2020
HOW TO GENERATE ENGLISH ALPHABET
The keyword for this task is chr() which take in number as argument and return equivalent character. E g chr(97) return 'a',with this we can generate our 26
English alphabet

alphabet=[chr(97+num) for num in range(26)]
print(''.join(alphabet))

Output: abcdefghijklmnopqrstuvwxyz


For capital letters start from 65

1 Like 1 Share

Health / Re: Francis Faduyile: We Are Not Going To Meet Or Interact With Chinese Medical Team by gbolly1151(m): 7:38am On Apr 12, 2020
Inviting Chinese doctor is unethical true,but the Govt themselves know that they haven't improve both education and medical sector which will post a serious danger on them when they are infected with this covid virus. This is just an alternative to flying out of the country for treatment. Those stupid Govt understand their motive.

16 Likes

Programming / Re: Common good python programming practices you should know by gbolly1151(m): 3:15pm On Apr 09, 2020
Tip for learning software development
Pick up python design patterns and learn
Programming / Re: Common good python programming practices you should know by gbolly1151(m): 12:24pm On Apr 09, 2020
Try and Except keyword
This is a wonderful keyword for controlling error output in python.
for example:
on a norm,dividing a number by 0(zero) is mathematical error,so if
you try to divide 2//0 in python,an awful error will be printed out
like this below,which cant be easily understood by user.


Traceback (most recent call):
2//0
ZeroDivisionError: interger division or modulou by zero


using Try and except keyword, you can control the output and print
out your desire output

let create two functions for out zero division error;
1.with try and except
2.without try and except


def div1(num):
try:
num=100//num
return num
except ZeroDivisionError:
return "Oop! You can't divide by zero"

#let divide 100/0
print('\noutput from div1 is "{0}"\n\n '.format(div1(0)))


def div2(num):
num=100//num
return num

#let divide 100/0
print('output from div2 is\n')
print(div2(0))



below pic show that,div1() give a nice output to the console than div2()
thanks to try and except for the job

1 Share

Programming / Re: Common good python programming practices you should know by gbolly1151(m): 12:24pm On Apr 09, 2020
Playforkeeps:

Thanks man, you’re doing a great job here man, we need more active Python/Django communities
True...i am hoping to create a Nigerian forum for it
Programming / Re: Common good python programming practices you should know by gbolly1151(m): 7:58am On Apr 09, 2020
Playforkeeps:
What im about to share isnt necessary a Practice, think of it as a tip. And it is how to setup a simple file server in python to be accessed by any client in your LAN. All you have to do is cd into the Server root directory and run
<code> python3 -m http.server <code/>
that will start a server on default port 8000 and if thats not suitable for you, you can pass in a custom port as an argument to the command.
Nice one
Programming / Re: Common good python programming practices you should know by gbolly1151(m): 9:05pm On Apr 06, 2020
locust:


Confused on which one to learn first; Java, python, Django, c# and the rest. I'm a rookie.

Those tips are advance anyway but i will advice you to pick up on one and learn,master it,then you can move on easily with other programing language.
Programming / Re: Common good python programming practices you should know by gbolly1151(m): 7:06pm On Apr 06, 2020
locust:
I don't even understand a thing from here.
Nnaa ehn
Which part and are you just learning python?
Programming / Re: Common good python programming practices you should know by gbolly1151(m): 11:18pm On Apr 05, 2020
Difference between yield and return

i will explain generator before going into yeild and return;

generator is a class that help to transform any object to work with
iter() and next()

Now what are yield and return?
Both keywords are used in returning value from a function but in different ways,

yield
1) release a generator object that called iter() method i.e
(yield = return genertor(object).__iter__()) and also
2) pause a function(it keep the state of function),then resume action when next() is called


return only help to terminate a function and release a value.


'''

       
#example of yield
def counter():
for i in range(10):
yield i**2
obj=counter() #generator object is return and state is kept for next call using
# next()
print(next(obj))
print(next(obj))
print(next(obj))
print('end my next call here')

'''
Recall that iter() and next() are brain behind for loop,therefore
we can use for loop on obj since it is iterable
'''

print('starting new next call with forloop')
for i in obj:
print(i)


#example of return

def counter():
for i in range(10):
return i

returnobj=counter()
print('return obj is',returnobj) #only 0 will be return then function terminate

1 Share

Programming / Re: Common good python programming practices you should know by gbolly1151(m): 5:31pm On Apr 04, 2020
iter() and next() KEYWORD

Iter() - is just used to make an object iterable,iterable objects
are use for forloop operation. this keyword call __iter__() method from the object, if not available then it throw error

next() - this keyword is use to access __next__() method of the object

inbuit data type that has this method are list,dictionary,set and tuple

With that you can make your class iterable e.g let create a data type that return
reverse of the any string


class String:
def __init__(self,string):
self.string=string
self.i=1

def __iter__(self):
return self

def __next__(self):
if abs(self.i) == len(self.string)+1 :
raise StopIteration
else:
value=self.string[-self.i]
self.i+=1
return value

for char in String('cat'):
print(char)

Output:
t
a
c


What happen behind the scene is this:
var=String('cat')
While True:
try:
Print(next(var))
except StopIteration:
break

'''var=String('cat')
s=iter(var)
print(next(s))
print(next(s))
print(next(s))'''

2 Likes 1 Share

Programming / Re: Common good python programming practices you should know by gbolly1151(m): 6:27pm On Apr 02, 2020
TIP TO LEARN OOP
To master OBJECT ORIENTED PROGRAMMING (OOP) start with CLASS DIAGRAM in UNIFIED MODELING LANGUAGE (UML),it will really help to know relationship between classes and make code writing easy.

1 Like 1 Share

Programming / Re: Common good python programming practices you should know by gbolly1151(m): 4:49pm On Apr 01, 2020
CONDITIONAL EXPRESSION
conditional expression help to assign a value to a variable based on a
given condition. the syntax is
var=expr1 if condition else expr2

This simply mean our var value will be expr1 if condition is True,else our
var value will be expr2


#example1: we are given a task to output if a number is positive or negative
#old code is

num=-10
def remark(num):
if num >= 0:
return 'positive'
return 'negative'

print(remark(num))

output= negative

#using short code with conditional expression

num= -10
remark='postive' if num >= 0 else 'negative'
print(remark)

#you can use this condition in any function directly too,so let use it in print #function
num= -10
print('postive' if num >= 0 else 'negative')
Programming / Re: Share Your Road map To Becoming A Web Developer. by gbolly1151(m): 1:43am On Apr 01, 2020
Samcent:
Good one for a start! I am also following your thread on 'Common good programming practices in python'. I love your passion and please keep it up.
If I may suggest, also add a JavaScript library, eg React, to your stack. Also, you will appreciate the beauty of django when you start building dynamic websites... I know you will definitely get there.

I learn programming and web development when my job affords me some spare time.

My path to web development :
- Basic python language
- Django framework
- HTML, CSS, Bootstrap, some JavaScript and Jquery while learning django
- Did some projects
- Deployment on pythonanywhere
- Back to learning JavaScript and Jquery in detail.
- Next will be adding React and ReactNative to the stack by God's grace.

Love and passion have kept me on this path. My only regret though, is that I did not join the party much earlier. However, my goal is to build web applications that will be relevant in my field of public health practice.


Thanks for your advice sir,i will keep to it

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