Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,152,721 members, 7,816,968 topics. Date: Friday, 03 May 2024 at 09:32 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) (of 16 pages)

Programming / Re: Common good python programming practices you should know by gbolly1151(m): 7:40pm On Apr 25, 2020
You can join my Facebook page @

https://m./2604470076495701
Programming / Re: Common good python programming practices you should know by gbolly1151(m): 6:37pm On Apr 25, 2020
HOW TO ASSIGN ANY FUNCTION TASK TO A VARIABLE
This is the basics learning of decorator,you need to understand
that you can assign a task to another variable,example
let assign print function to another variable

var=print
var('hello world')

Output:
hello world

In example above,we are assigning the power of print to var no more no less and that is the main trick behind a decorator
Programming / Re: Common good python programming practices you should know by gbolly1151(m): 7:41pm On Apr 24, 2020
Example on how to use filter,lambda and dict to output highest goal scorer


scores={'messi':3,'Ronaldo':1,'ighalo':2,'Giroud':7,'kane':7}

def Highest_goal_scorer(scores):
goal=max(scores.values()) #highest goal
scorer_filter=filter(lambda player:scores[player] == goal,scores) #filter highest
scorer=[player for player in scorer_filter ]
return scorer
print(Highest_goal_scorer(scores))

Output:
['kane','Giroud']
Software/Programmer Market / Re: Learn Python Programming @ Affordable Price By Building A Project by gbolly1151(m): 6:46pm On Apr 24, 2020
Course - Django
Duration - 6weeks
Price - #10000
Available slot - 5people
Requirement - must know python basics and advanced

Example of my project build with django
/http://mydemoapp12345.herokuapp.com/

We will learn it by building a blog
Software/Programmer Market / Re: Learn Python Programming @ Affordable Price By Building A Project by gbolly1151(m): 6:40pm On Apr 24, 2020
Course - python basics
Duration - 4weeks
Price - #4000
Available slot - 5people
Requirement - No any prior knowledge
Programming / Re: Common good python programming practices you should know by gbolly1151(m): 6:36pm On Apr 24, 2020
Hi guys, if you are interested in learning python checkout for details here

https://www.nairaland.com/5814602/learn-python-programming-affordable-price#88811892
Software/Programmer Market / Learn Python Programming @ Affordable Price By Building A Project by gbolly1151(m): 6:33pm On Apr 24, 2020
Hello Nairaland, Here is me again,the author of the following threads on Nairaland

Common good python programming practices
https://www.nairaland.com/5549856/common-good-python-programming-practices

Tutorial - object oriented programming paradigm
https://www.nairaland.com/5793559/tutorial-object-oriented-programming-paradigm

I am opening this thread for people who want to learn python program at affordable price.

Python is a versatile programing language which can be used in web development (backend),software development, machine learning model,Deep neutral network model,script writing(to automate a task),Internet of things, Robotics, Blockchain, cryptography, Ethical hacking etc.

In this thread,i will keep you update with our available class,Price and duration of learning

To reach me call 07060435624
Nairaland / General / Why Snake Post Always Get To FP by gbolly1151(m): 9:21pm On Apr 23, 2020
I have been on Nairaland for a while and notice that post related with snake always get to the front page why?
Programming / Re: Common good python programming practices you should know by gbolly1151(m): 9:42am On Apr 23, 2020
How to setup dictionary with default value
Let say you have a list of players and want to create a script to count their goals.

The first action is to set their goal to default value 0 and keep up updating

As a coder,what will come to your mind to create dictionary with default value 0 is iterate the list


#naive approach
players=['messi','Ronaldo','ighalo']
goals={}
for player in players:
goals[player]=0

print('Goals:',goals)

Output:
Goals : {'messi':0, 'ighalo':0, 'Ronaldo':0}


#fast approach

players=['messi','Ronaldo','ighalo']
goals=dict.fromkeys(players,0) #dict.fromkeys(iterable-object,default-value)

print('Goals:'goals)

Output:
Goals : {'messi':0, 'ighalo':0, 'Ronaldo':0}



1 Like 1 Share

Programming / Re: Programming by gbolly1151(m): 8:44pm On Apr 22, 2020
1.pick up any language that support OOP e.g c ,c#,c++ ,python,java
2. Learn the basics and solve questions as many as possible
3. Learn Data structure and Algorithm (know how to Big-Oh notations and the likes)
4a. Learn OOP
4b. Learn object Relationship (inheritance, composition and aggregate, association)
5. Learn class diagram and practice many questions by drawing class diagram for popular system like atm system, order system etc
6. Continue learning

3 Likes

Programming / Re: Common good python programming practices you should know by gbolly1151(m): 3:31pm On Apr 22, 2020

#To glance through a moudle and check availability method use this function
#dir(name of module) e.g dir(list)
print(dir(list))


You can also import a module and check the method available


import os
print(dir(os))


To check how to use a function use help() eg help(list.append)

Programming / Re: Tutorial: Object Oriented Programming Paradigm For Beginners in Python by gbolly1151(m): 4:46pm On Apr 21, 2020
Object Relationship
Interaction among objects is what lead to a system, the working of a system depends on how these objects interact and these interaction is what we called Relationship. These relationship are of 3 type in OOP;

1. Inheritance
2. Association
3. Composition and Aggregation

1. INHERITANCE : This is the most common relationship among objects that share a relationship 'is a type of' between objects. when two or more objects have slight difference then they must have belong to the same object. When object A,object B,object C are type of Object D we call it inheritance,they are also called generalization.
Examples:
Teaching staff and Non Teaching staff are type of Staff,
saving account and current account are type of bank account
Yoruba,igbo,hausa are type of Tribes.
Parrot and penguin are type of type

Let see a description to understand better

DESCRIPTION OF PARROT
Parrot is a bird
It has feathers
It can fly but can't swim

DESCRIPTION OF PENGUIN
Penguin is a bird
It has feather
It can't fly but can swim

Looking at these two description,we can see that both have common name(bird) and attribute i.e they have feather but different method

To prevent repetition of code,we can create a class bird and allow both parrot and penguin to inherit it. To inherit here ,we mean they should have assess to bird class


Class:
Name - Bird
Attribute - feather

class(bird):
#we are going to inherit the bird's attribute so we won't create attribute for parrot #again
Name - parrot
method - fly()

class(bird):
Name - penguin
method - swin()
#since penguin can't fly,we dont need to include it into the method

#implementation in python
class bird:
def __init__(self):
self.feather= True

class Parrot(bird): #to indicate that we want to inherit bird
def __init__(self):
#calling bird.__init__()(super().__init__()) is necessary to implement
# bird's attribute in parrot
super().__init__()

def fly(self):
return 'i am flying'

class Penguin(bird):
def __init__(self):
super().__init__()

def swim(self):
return 'I am swimming'

myparrot=Parrot()
mypenguin = Penguin()

print(myparrot.feather) # i can call feather from bird because parrot inherit it
print(mypenguin.feather)
print(myparrot.fly())
print(mypenguin.swim())

Output:
True
True
I am flying
I am swimming


This actually help us to structure our code and object
Programming / Re: Tutorial: Object Oriented Programming Paradigm For Beginners in Python by gbolly1151(m): 10:23am On Apr 21, 2020
gbolly1151:


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

Before we move to inheritance, let implement this in python


class Animal:
def __init__(self,legs,Tail=True,Body):
self.legs=legs
self.Tail = Tail
Sel.Body = Body

def bark(self):
return 'barking'

def bite(self):
return 'biting'

def run(self):
return 'running'

#let create our object

Dog=Animal (4,Tail=True,'fat')

#you can leave out tail if true and create like this Dog=Animal(4,'fat')
print(Dog.legs)
print(Dog.Tail)
print(Dog.Body)
print(Dog.bark())
print(Dog.run())
print(Dog.bit())

Output:
4
True
fat
barking
running
biting
Health / Re: Coronavirus Update In Kano: 1 Death, Total Of 59 Confirmed Cases by gbolly1151(m): 9:50am On Apr 21, 2020
From recent result, A question has been coming through my mind

Is Government manufacturing the number of infested people?
1. If Yes,probably government want to chop the donating funds at hand

2.If No,then I knew it,when i posted in a thread that,govt should take northern side serious about spread, now it is happening, my aboki are known not to take health serious,simple safety precautions they can't keep. Their Religion/culture has really enslave their minds

The game has just started, i predict 500 soon from northern side between now and next two weeks unless they don't test them properly.
Programming / Re: Why Is Python Programming So Hard To Understand by gbolly1151(m): 6:54pm On Apr 20, 2020
locust:


I tried replicating what was done in this book.
To replicate that book, change line 3 to myname=input().
when you run it, you will see a prompt requesting you for keyboard action, then you put your 'locust'. Those bold statement in that tutorial material are input from keyboard

1 Like

Programming / Re: Common good python programming practices you should know by gbolly1151(m): 2:50pm On Apr 20, 2020
ALWAYS CREATE VIRTUAL ENVIRONMENT FOR YOUR PROJECT

Virtual Environment is a an isolated environment from the main environment.Each projects in one way or the other will depend on external package,that need to be install before use.

If all packages for projects A and project B are downloaded in the same environment, it will be really difficult to manage when it is time to deploy. To manage your project dependency,virtual environment can handle the task for you where each projects will operate in different environment and there wont be any headache when need for obtaining information about dependency for each projects

To get started open your Command line and install virtualenv

#install the virtual environment
pip install virtualenv

#create directory for your project
mkdir projectA

#open the directory
cd project A

#create your virtual environment
#env - is the name you wish to give your environment
python3 -m venv projectAenv

#myprojectAenv directory will be created inside projectA dir

#now i have to activate the environment so that i can be working
#from the environment

projectAenv/bin/activate

#something like below will show which indicate the environment myprojectAenv
#has been activated
(myprojectAenv)

#minimize and start working on projectA
#To install dependency for projectA,come back to command prompt
#ensure that your environment for projectA is activated by looking at
#in our case (myprojectAenv) is our virtual environment for projectA
#so let install numpy package for projectA

(projectAenv) pip install numpy

#To test your installation
Python
>> import numpy
>>
#if no error it means installation is successful in projectA environment

#to deactivate the environment

(projectAenv) deactivate

#if you now import numpy after you deactivate the environment error will show
#because you are in new environment, i.e main environment




You can create many environment as many as you like,just know the project they are working for,the name you give the env can help.

1 Like 1 Share

Programming / Re: Why Is Python Programming So Hard To Understand by gbolly1151(m): 1:46pm On Apr 20, 2020
locust:
Please why is line 3 ignored?

I expected the answer series to be:

°Hello World!
° What is your name?
°Locust
°Good to see you Locust
°The length of your name is:

Why was °Locust ignored?
Because you dont use the keyword or funtion print() in line 3,only what you command to print is what the code will print...
Programming / Re: Tutorial: Object Oriented Programming Paradigm For Beginners in Python by gbolly1151(m): 2:36am On Apr 20, 2020
Predstan:


Object - Lion


Class:
Name - Animal
Attributes - short, rounded head, , reduced neck, round ears, hairy tufts at the ending of its tail
Method - run(), jump(), hunt prey()

Well done boss.... but let me comment on your answer

head is the attribute name while rounded and short are the values same as other attribute name


attribute - head = [short,rounded] <== value
neck=reduce <== value
ears= round <== value
tuff = hairy <==value


You can practice more,just pick up objects around you and describe them

I will start inheritance in next update
Programming / Re: Common good python programming practices you should know by gbolly1151(m): 12:04am On Apr 20, 2020
Programming / Re: Common good python programming practices you should know by gbolly1151(m): 10:25pm On Apr 19, 2020
HOW TO WORK WITH FILE

#avoid opening file this way
file=open('myfile.txt','r')
file.close()

#you might forgot to close the file which means operation can be done
#inside the file

#use this
with open('myfile.txt','r') as file:
#do something

#the indentation cover you up and no need to worry about closing the file

Programming / Re: Why Is Python Programming So Hard To Understand by gbolly1151(m): 1:04pm On Apr 19, 2020
Anytime you get to a point you feel it is hard in python,just take a break and pick it up again when your brain get relaxed

3 Likes

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