Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,151,369 members, 7,812,066 topics. Date: Monday, 29 April 2024 at 07:36 AM

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) (15) (16) (of 16 pages)

Programming / Re: IT Gurus Here Pls Help Me Answer This Question by gbolly1151(m): 11:20am On Dec 11, 2019
If a software malfunction who is at fault?

1 Like

Programming / Re: Common good python programming practices you should know by gbolly1151(m): 8:46am On Dec 09, 2019
Jesse25:

I mean the website I can use too run d program

Website for Hosting your code?
Programming / Re: Common good python programming practices you should know by gbolly1151(m): 6:20pm On Dec 08, 2019
gbolly1151:

#Run math python script and expression with eval()
#Take for instance input = 2+4*5-6
#instead of writing long algorithm you can solve easily with eval()

Math_expression = input(' type your math expression :')
try:
Ans = eval(math_expression)
print(f'output : {Ans}')
except:
print('invalid basic math operations')

Input : 2+4*5-6
Output : 24

Be careful when using this function because your system can be access through this....the eval() just help to run python script which means any python script can be run through eval()
Programming / Re: Common good python programming practices you should know by gbolly1151(m): 6:17pm On Dec 08, 2019

#Run math python script and expression with eval()
#Take for instance input = 2+4*5-6
#instead of writing long algorithm you can solve easily with eval()

Math_expression = input(' type your math expression :')
try:
Ans = eval(math_expression)
print(f'output : {Ans}')
except:
print('invalid basic math operations')

Input : 2+4*5-6
Output : 24
Programming / Re: A Talented Nigeria Entrepreneurs Develop The Best Communication And Chatting App by gbolly1151(m): 1:01pm On Dec 08, 2019
Stephenogar:
is the app here?

Am sorry,if you are really offended. From the pic you share,it is a resemblance of whatsapp, try to change the makeup and have a wonderful app. Your backend might be wao!!! But trust me the frontend need new look not the one we are used to.

And kudos to you guys,if you really built it from scratch.

Together we can represent Nigeria well in computing world
Programming / Re: Common good python programming practices you should know by gbolly1151(m): 12:47pm On Dec 08, 2019
Jesse25:

pls which tool can i use too execute a program like python
I don't really your question.... Do you mean IDE?
Programming / Re: A Talented Nigeria Entrepreneurs Develop The Best Communication And Chatting App by gbolly1151(m): 7:48pm On Dec 07, 2019
Lolz...we are not blind here na,you clone someone else work and call it best
Programming / Re: How Much Do You Know In Python? by gbolly1151(m): 12:31pm On Dec 06, 2019
Questions 1
How can private variables and functions be created in python?
Programming / How Much Do You Know In Python? by gbolly1151(m): 12:29pm On Dec 06, 2019
I welcome you all to this thread
This thread is created purposely to improve our knowledge in python programming language as we will be checking on technicalities involve in python itself to be able to write a good and memory friendly app in python programming language
Everybody is allow to drop technical questions and we all tackle it together
Once again welcome to this thread

#together_we_build_Nigerian_programmer
Programming / Re: Common good python programming practices you should know by gbolly1151(m): 7:50am On Dec 06, 2019

# how to search for index of multiple chars in a string
s='sleep'

#first index of e
# hint: the syntax of index method is index( string, start, stop)
# string - the string to search
# start - where to Begin search,by default search Begin at 0 i.e the beginning of the string
# stop - where search to stop ,by default search stop at the end of the string

f_index = s.index('e') #output = 2

S_index =s.index('e', 3) #output = 3

#using iteration to find more than 2 chars in a string

s=' sleeping eeee '
Start_position=0
for i in range(s.count('e')):
Start_position = s.index('e' , Start_position)
print(f' e found at position: {Start_position}')
Start_position+=1

Phones / Re: This Is How Fast MTN 5G Network Is! by gbolly1151(m): 12:53pm On Dec 04, 2019
Hope they will reduce data plan
Crime / Re: Abia Armed Robber "Grave" Finally Goes To The Grave (Graphic Photos) by gbolly1151(m): 12:44pm On Dec 04, 2019
Hmm....his name finally worked for him now

1 Like 1 Share

Programming / Re: If You Interested In Learning And Earning From Bug Bounty Hacking, Jump Right In by gbolly1151(m): 1:48am On Dec 04, 2019
07060435624
Programming / Re: Common good python programming practices you should know by gbolly1151(m): 12:45am On Dec 03, 2019

#how to arrange a list in ascending order
sorted([3,6,1,2]) #output [1,2,3,6]

#in decending order
sorted([3,6,1,2],reversed = True) # [6,3,2,1]
Programming / Re: Common good python programming practices you should know by gbolly1151(m): 12:02pm On Nov 30, 2019

#how to output dict variable

Nums = {"one" : 1,"two" =2, "three" : 3 }
for key,value in nums.items():
print(f'{key} - {value}')

#output
# one - 1
#two - 2
#three - 3
Programming / Re: Common good python programming practices you should know by gbolly1151(m): 11:36am On Nov 30, 2019

# To accept multiple variable into a function
def num(*arg):
print(*arg)

num(1,2,3,4) # output = 1 2 3 4
num(1) #output=1
num('hello','world') #output=hello world

# To accept multiple keyword variable into a function
def num(**a):
for i,k in a.items():
print(k)


num(a="heloo",b="5" ) #output hello,5



Programming / Re: Common good python programming practices you should know by gbolly1151(m): 11:28am On Nov 30, 2019

#bad style
X = X + 1

#good style
X += 1 #can be use for other arithmetic operations
Programming / Re: Help On Deployment On Heroku by gbolly1151(m): 4:31pm On Nov 29, 2019
Ajibel:


I haven't had any experience using heroku in this case but what I know is that since the config var you set from the start are persistent, then you wont need to set a new config var again whenever your app is restarted.

Yea thanks...got it now....after reading their doc, i knew that the config var are kept just like the source code. Whenever dyno loads, config var are set in the environment. So no need of setting the config var again
Programming / Re: Python Programmers Hang-out by gbolly1151(m): 1:18pm On Nov 29, 2019
It been a while here,let hook ourselves with a question here

On heroku, I understand that dyno is a virtual file system on which django app are served and can go off anytime, when this happen, do i need to set the config var again to start my app when dyno is on again?
Programming / Re: Help On Deployment On Heroku by gbolly1151(m): 12:10pm On Nov 29, 2019
Ajibel:


It depends on your choice. I don't know the best, but I have used several patterns. Here is an idea of what I do with Flask:

if os.environ.get('SECRET_KEY'):
........SECRET_KEY = os.environ.get('SECRET_KEY')
else:
........SECRET_KEY = 'SECRET_KEY_ENV_VAR_NOT_SET'
........print('SECRET KEY ENV VAR NOT SET! SHOULD NOT SEE IN PRODUCTION')

But again I think to have a .env file where you set your private keys and read from it is what I have seen many open source projects do. Since you're using heroku, go through their django setup walkthrough. I believe whatever pattern they make use of there is what you should go with.

Thanks it is really helpful

I understand that dyno is a virtual file system on which django app are served and can go off anytime, when this happen, do i need to set the config var again to start my app when dyno is on again?
Programming / Re: Assistance With Ethereum Smart Contracts Using Python by gbolly1151(m): 12:57am On Nov 29, 2019
I think you need to learn how ethereum Blockchain works first and how contract are created. You can easily learn it fast because the solidity language used is similar to JavaScript and there is a testnet environment for you to test your project at no cost. Python can only send data to Blockchain and interact with the contract by mimicking the block format
Programming / Re: Common good python programming practices you should know by gbolly1151(m): 12:29am On Nov 29, 2019

a,b,c= 'hey','hello','world'

#old string formating
print(a,b,c)

#new string formatting
print(f'{a} {b} {c}')
Programming / Re: Common good python programming practices you should know by gbolly1151(m): 12:24am On Nov 29, 2019


#in some cases you may want to assign value to some variable that are nearing #in the same category or having mutual relationship

#old way is

a="hello"
b="world"
c="!!!"

#good programming is
a,b,c='hello', 'world', '!!!'

1 Like

Programming / Re: Coding Looks Cool. by gbolly1151(m): 8:07am On Nov 28, 2019
For people who will be writing code you can use this tag

[Code] [/Code] (make C small letter) to make the code easy to read for programmers the output will be similar to below code


def greet('hello world):
return 'hello world'

print('hello world')

1 Like 1 Share

Programming / Re: Common good python programming practices you should know by gbolly1151(m): 7:43am On Nov 28, 2019

#old way of file operation
f=open('test.txt','rb')
f.write(b'hello world')
f.close()

#fast way
with open('test.txt','rb') as f:
f.write(b'hello world')
Programming / Re: Common good python programming practices you should know by gbolly1151(m): 11:46pm On Nov 27, 2019
chidemavian:
There are factually no cheats in Python nor any other language.


What u tried to demonstrate in the first example is known as list comprehension.



Its good practice in programming, as is in other professions, to give the right name to the right concept




Don't misslead the public


Thanks.


If u want to reach me.....click here

https:///23407031009036

I personally called them cheat because they are short cut in getting things done....dont be offended if the naming sounds bad to you
Programming / Re: Help On Deployment On Heroku by gbolly1151(m): 8:46am On Nov 27, 2019
Ajibel:
In case 1 it means the default value you set would be used as secret key if you didn't set a SECRET KEY in heroku's env.

In case 2 because there's no default, an error will be thrown if you fail to set the key in the env

Which one is the best?
Programming / Help On Deployment On Heroku by gbolly1151(m): 3:08pm On Nov 26, 2019
When deploying django to heroku why should

(Case1)
SECRET_KEY = os.environ.get("SECRET_KEY", "YBWHGRHH"wink

INSTEAD OF

(Case2)
SECRET_KEY=os.environ['SECRET_KEY']

In my own view the secret key is been exposed in case 1 but more secured in case2
Programming / Re: Common good python programming practices you should know by gbolly1151(m): 10:31am On Nov 26, 2019

#old way of finding square of a number
def old_square (num):
return num*num

#fastest way
square = lambda num : num*num

print(old_square (5)) #output is 25
Print(square (5)) #output is 25

1 Like

Programming / Re: Common good python programming practices you should know by gbolly1151(m): 9:57am On Nov 26, 2019

#how to print negative numbers
Elements = [ element for element in range (0,-10,-1)]
Programming / Re: Common good python programming practices you should know by gbolly1151(m): 9:14am On Nov 26, 2019
Am starting with list

You can populate your list with a single line of code



#old coding practice to populate list object
Elements = []
for element in range (10):
Elements.append(element)
print(Elements)

#new coding practice to populate list object
Elements = [ element for element in range(10) ]

3 Likes

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