Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,153,151 members, 7,818,473 topics. Date: Sunday, 05 May 2024 at 04:44 PM

Python Programming - Programming (11) - Nairaland

Nairaland Forum / Science/Technology / Programming / Python Programming (61735 Views)

Anyone That Know Python Programming Should Help Me To Check The Eorr This / Support Python Programming With Android Devices :qpython E.t.c / What Can Python Programming Language Build? (2) (3) (4)

(1) (2) (3) ... (8) (9) (10) (11) (12) (13) (14) (Reply) (Go Down)

Re: Python Programming by 4kings: 2:21pm On Oct 23, 2016
melodyogonna:
is this thread dead?
You can bring life to it. wink
Re: Python Programming by melodyogonna(m): 3:17pm On Oct 23, 2016
4kings:

You can bring life to it. wink
i just wan ask if pesin go helep me suggest one ogbonga site wher i fit learn photoshop, and anoda tin b say i wan knw weda photoshop nd photopaint relate i.e if i fit do the same tin wey i dey do with photoshop 4 photopaint.
Re: Python Programming by Ihinmi(m): 1:30am On Oct 26, 2016
Ajibel:

Do you use Django atall?
please which version should I use as a starter 3 or 2. Thanks.
Re: Python Programming by Ajibel(m): 6:16am On Oct 26, 2016
Ihinmi:

please which version should I use as a starter 3 or 2.
Thanks.

Django doesnt have a version 3 or 2. It's Python that does.

You can either go for the latest stable version of Python 2.7.11 or Python 3.5.x. If you don't know which to use, go with Python 3.5.

For Django, use version 1.10.2

You're welcome.

1 Like

Re: Python Programming by Ihinmi(m): 7:17am On Oct 26, 2016
Ajibel:


Django doesnt have a version 3 or 2. It's Python that does.

You can either go for the latest stable version of Python 2.7.11 or Python 3.5.x. If you don't know which to use, go with Python 3.5.

For Django, use version 1.10.2

You're welcome.

Thanks, what I meant is python then I will go with 3
Re: Python Programming by Ajibel(m): 8:22am On Oct 26, 2016
Ihinmi:


Thanks, what I meant is python then I will go with 3

Alright then. Go with Py3k and dont look back. cool
Re: Python Programming by abledigital(m): 7:39am On Dec 09, 2017
we have a website that is developed on python, we need a developer that have knowledge in python language and also in cryptocurrencies that will work for us on our website.
Re: Python Programming by Nmeri17: 2:02pm On Dec 09, 2017
Re: Python Programming by harnuh01(m): 4:21pm On Dec 09, 2017
adejumoadeoluwa:
hello there is a whatsapp group for python programmers, see my number in the signature if you are interested in joining
09096460769
Re: Python Programming by Nobody: 5:33pm On Dec 10, 2017
I just started learning Python. I will be using it for my Msc project soon.
Re: Python Programming by lexaydfg(m): 12:31am On Dec 14, 2017
I started learning python from my phone just reading ebooks and watching youtube videos basically, but by God's grace will soon get a laptop to practice and learn well.

I don't mind if I can get a tutor who will guide me.
Re: Python Programming by efficiencie(m): 1:44am On Apr 07, 2018
You guys started something as great as this and vanished ... shocked shocked shocked Wia una dey make una show o. I am a newbie to Python programming and I think posting and solving beginner python programming exercises would not only go a long way in keeping this thread alive but will spur the growth in the skills of new python programmers...Problem solving will keep this thread alive.

I saw this problem on a python programming facebook group (tis for newbies anyway):

Construct a python program that returns the number of occurrences of a substring in a string if the string does not end with the substring or returns one less of the number of occurrences of a substring in a string if the string does end with the substring.

For example, the solution must return 2 in the string 'adedasaasfdfdfsds' if the substring is 'fd' or the solution must return 4 if the string is 'adddddffggdd' and the substring is 'dd'. Note that in the last example 'dd' occurs 5 times in the string as it appears 4 times in 'ddddd' and once in 'dd' but this last count is disregarded since the specified string ends with 'dd'.

You are only permitted to use: LOOPS, CONDITIONAL STATEMENTS, BREAK, CONTINUE, USER DEFINED FUNCTIONS OR GENERATORS.
Re: Python Programming by Damoxy(m): 1:46pm On Apr 07, 2018
Is any body into Big Data Analysis or someone Good with R language?
Re: Python Programming by 4kings: 3:32pm On Apr 07, 2018
Damoxy:
Is any body into Big Data Analysis or someone Good with R language?
Yep.
Watsup?
Re: Python Programming by 4kings: 3:49pm On Apr 07, 2018
efficiencie:
You guys started something as great as this and vanished ... shocked shocked shocked Wia una dey make una show o. I am a newbie to Python programming and I think posting and solving beginner python programming exercises would not only go a long way in keeping this thread alive but will spur the growth in the skills of new python programmers...Problem solving will keep this thread alive.

I saw this problem on a python programming facebook group (tis for newbies anyway):

Construct a python program that returns the number of occurrences of a substring in a string if the string does not end with the substring or returns one less of the number of occurrences of a substring in a string if the string does end with the substring.

For example, the solution must return 2 in the string 'adedasaasfdfdfsds' if the substring is 'fd' or the solution must return 4 if the string is 'adddddffggdd' and the substring is 'dd'. Note that in the last example 'dd' occurs 5 times in the string as it appears 4 times in 'ddddd' and once in 'dd' but this last count is disregarded since the specified string ends with 'dd'.

You are only permitted to use: LOOPS, CONDITIONAL STATEMENTS, BREAK, CONTINUE, USER DEFINED FUNCTIONS OR GENERATORS.
I don't understand this part: "or returns one less of the number of occurrences of a substring in a string if the string does end with the substring."
Re: Python Programming by Damoxy(m): 4:23pm On Apr 07, 2018
4kings:
Yep.
Watsup?
Good Day,can we talk on WhatsApp?
Re: Python Programming by 4kings: 5:27pm On Apr 07, 2018
Damoxy:

Good Day,can we talk on WhatsApp?
I just sent you a PM. Contact me via mail.
Re: Python Programming by Damoxy(m): 10:06pm On Apr 07, 2018
4kings:
I just sent you a PM. Contact me via mail.
Alright
Done
Re: Python Programming by efficiencie(m): 2:20am On Apr 08, 2018
4kings:

I don't understand this part: "or returns one less of the number of occurrences of a substring in a string if the string does end with the substring."

I meant in the case of a string say 'adddasadd' if the substring whose number of occurrences in the specified string we seek is 'dd' then the number of occurrences of 'dd' must not include the bolded in 'adddasa dd ' since the specified string ends with 'dd'. So in this case your script must return 2 because there are 2 occurrences of 'dd' in the bolded 'a ddd asadd'. The two occurrences are bolded respectively: 'a dd dasadd' and 'ad dd asadd'. I hope it is clearer now!
Re: Python Programming by efficiencie(m): 2:25am On Apr 08, 2018
I wana ask; is there any specific and generally acceptable style for writing algorithms (i.e pseudocode specifically)? If there are any resources on the internet that can help please can anyone suggest some.
Re: Python Programming by Nobody: 4:19pm On Apr 08, 2018
efficiencie:
I wana ask; is there any specific and generally acceptable style for writing algorithms (i.e pseudocode specifically)? If there are any resources on the internet that can help please can anyone suggest some.
Pseudecodes are pretty simple I don't think there's any special way of writing them.

But if you are talking about style of writing algorithms there arelgorithm design patterns e.g recursion, Greedy etc

1 Like

Re: Python Programming by Alejob: 3:56am On Apr 09, 2018
Are you in need of a portable energy solution that is efficient and can be carried around without stress ..... I recommend Mobile Power Solution for you


This setup can power your TV LED plus Decoder (5hours plus) , Laptop (10-24hrs+) , Phone/Tab (a week) Light Bulb (Days), Clipper (10hrs+), e.t.c. and the icing on the cake is that it is exceptionally mobile.....you easily charge at work and use at home or add solar panel to charge it during the day


If you are into freelancing, coding, programing, manuscript editing, data analysis or working with Autocad, Archicad or work for lengthy hours on laptops.... At the price of 35K.....this is a must have.....


It can be recharge back in about 4 -5 hours
Compatible with all laptop and many electronic device....

Extremely mobile and therefore
Improves productivity and entertaining hours everywhere and anywhere
Compact and easy to carry about
Quite affordable and no maintenance needed

Maximum load capacity is 100watt... So overloading is a no no

Price: N35, 000

For more info, contact: 08065316307
oladipoadeyeye@gmail.com
Cheers!

https:///Cf4dTuhBnLM5sBXo0hN17I


https://www.nairaland.com/1565780/power-bank-power-tv-decoder


https://www.youtube.com/watch?v=puMRpTOwnNM
Re: Python Programming by efficiencie(m): 10:21am On Apr 10, 2018
Write a function that converts a string containing an ordered sequence of positive whole numbers and number ranges to an ordered list of those numbers, that it returns.

Number are separated with commas (and optional spaces) and number ranges are marked with a - between two whole numbers (with optional spaces either side).

For bonus points and handle out of order sequences and reverse ranges. Return an ordered list of unique numbers.

State your assumptions (so interpret the challenge your way).

For example,

‘1-5, 7, 9, 10-13’ should convert to [1, 2, 3, 4, 5, 7, 9, 10, 11, 12, 13]
Re: Python Programming by efficiencie(m): 10:26am On Apr 10, 2018
efficiencie:
You guys started something as great as this and vanished ... shocked shocked shocked Wia una dey make una show o. I am a newbie to Python programming and I think posting and solving beginner python programming exercises would not only go a long way in keeping this thread alive but will spur the growth in the skills of new python programmers...Problem solving will keep this thread alive.

I saw this problem on a python programming facebook group (tis for newbies anyway):

Construct a python program that returns the number of occurrences of a substring in a string if the string does not end with the substring or returns one less of the number of occurrences of a substring in a string if the string does end with the substring.

For example, the solution must return 2 in the string 'adedasaasfdfdfsds' if the substring is 'fd' or the solution must return 4 if the string is 'adddddffggdd' and the substring is 'dd'. Note that in the last example 'dd' occurs 5 times in the string as it appears 4 times in 'ddddd' and once in 'dd' but this last count is disregarded since the specified string ends with 'dd'.

You are only permitted to use: LOOPS, CONDITIONAL STATEMENTS, BREAK, CONTINUE, USER DEFINED FUNCTIONS OR GENERATORS.



Here is my solution :

"""
Given a string object word, compute the 'overlapping' frequency
of substr excluding the last n(substr) characters of word if
word terminates with substr
"""

def dellast(substr, word):
"""
delete the last n(substr) characters of the string word if word
ends with the substring substr
"""
j = 0
for i in substr:
j += 1
nsubstr = j
j = 0
for i in word:
j += 1
nword = j
j = 0
sub = ""
for i in word:
j += 1
if j >= nword - nsubstr + 1:
sub += i
if sub == substr:
j = 0
sub = ""
for i in word:
j += 1
if j <= nword - nsubstr:
sub += i
return sub
else:
return word

def delfirst(nsubstr, word):
"""
delete the first nsubstr character(s) of the string word if word
ends with the substring substr
"""
j = 0
sub = ""
for i in word:
j += 1
if j > nsubstr:
sub += i
return sub

def substrseq(substr, word):
"""
produce an iterable which is a sequence of substrings of word of
lenght nsubstr with each consecutive substring overlapping (i.e
each consecutive substring share nsubstr - 1 characters)
"""
word = dellast(substr, word)
j = 0
for i in substr:
j += 1
nsubstr = j
j = 0
sub = ""
while word != "":
for i in word:
j += 1
sub += i
if j == nsubstr:
yield sub
sub = ""
j = 0
break
word = delfirst(1, word)

def substrcount(substr, word):
j = 0
for i in substrseq(substr, word):
if substr == i:
j += 1
return j

def count(substr, word):
print("The number of times: \"", substr, "\" occurs in \"", \
word, "\" is: " )
print(substrcount(substr, word))
Re: Python Programming by efficiencie(m): 5:15pm On Apr 11, 2018
Wow! No python enthusiasts here? 4kings, melodyogona, etc where una...
Re: Python Programming by efficiencie(m): 5:18pm On Apr 11, 2018
efficiencie:
Write a function that converts a string containing an ordered sequence of positive whole numbers and number ranges to an ordered list of those numbers, that it returns.

Number are separated with commas (and optional spaces) and number ranges are marked with a - between two whole numbers (with optional spaces either side).

For bonus points and handle out of order sequences and reverse ranges. Return an ordered list of unique numbers.

State your assumptions (so interpret the challenge your way).

For example,

‘1-5, 7, 9, 10-13’ should convert to [1, 2, 3, 4, 5, 7, 9, 10, 11, 12, 13]

I got this problem from a facebook Python group and was able to find a solution for it though my code may not be the faster but any other coder can supply his solution so we can compare and learn.

"""
This function accepts a single string of comma seperated integers or ranges
in any order and converts the string to a sequence of ordered integers
"""
def string2seq(string):
collect = []
for i in string.split(','):
try:
j = i.split('-')
jj = int(j[0])
jjj = int(j[1])
while jj <= jjj:
collect += [jj]
jj += 1
except:
j4 = int(i)
collect += [j4]
collect.sort()
return collect
Re: Python Programming by 4kings: 1:24pm On Apr 15, 2018
efficiencie:
Wow! No python enthusiasts here? 4kings, melodyogona, etc where una...
Been busy...
Cool solution. smiley
Re: Python Programming by waali(m): 7:51am On Apr 17, 2018
efficiencie:
Write a function that converts a string containing an ordered sequence of positive whole numbers and number ranges to an ordered list of those numbers, that it returns.

Number are separated with commas (and optional spaces) and number ranges are marked with a - between two whole numbers (with optional spaces either side).

For bonus points and handle out of order sequences and reverse ranges. Return an ordered list of unique numbers.

State your assumptions (so interpret the challenge your way).

For example,

‘1-5, 7, 9, 10-13’ should convert to [1, 2, 3, 4, 5, 7, 9, 10, 11, 12, 13]
Here's the screenshot of my solution attached below... Now to the explanation and assumption

1. I assume assume aside the spaces separating the numbers, the user input space at the beginning or ending of the string. So my way of dealing with this is to first remove all the spaces in the string and that's what I did on line 2.

2. Since the list would likely contain number range, I introduced a mechanism for checking whether each of the items in the string_list variable is just a number or a range and this would determine how the data is been handled.

4. If the item is a range i.e contains a hyphen(-) then I need to get the start and end number and pass it to the range function which would be looped over, converted into an integer and added to the output list.

5. If the item is just a number, it is converted into an integer and added to the list.

6. Lastly, I use the set and list function to make sure the list returned as output is unique.

Note: There's still some error handling issues not incorporated into the code for simplicity and because I am just passing and felt I should just try. One of such is how you handle non numeric items. With your isdigit and isapha methods on string, that would be taken care of.

Re: Python Programming by ndizzy(m): 9:05am On Apr 17, 2018
Join us in Minna, Niger State as we kick start a python learning community. It is scheduled for 26 May 2018.
Re: Python Programming by efficiencie(m): 1:38pm On Apr 18, 2018
Write a Python function that prints out the first n rows of Pascal's triangle.
for example if n=5 the output must be:
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
where n is a parameter of the function
Re: Python Programming by efficiencie(m): 1:17pm On Apr 19, 2018
efficiencie:
Write a Python function that prints out the first n rows of Pascal's triangle.
for example if n=5 the output must be:
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
where n is a parameter of the function

Re: Python Programming by efficiencie(m): 2:19am On Apr 29, 2018
BEGINNER CHALLENGE (copied)

Sliding window array multiplication.


NOTE < and > symbols in the below surround variable names to indicate you can use your own name in place of what is used in this text, they are not part of the Python syntax.

Write a function that returns a list of results of some array multiplications as described below.

Your function must accept as parameters two numeric lists, we shall call them <sliding> and <base>, and return one numeric list, <answers>.

Note that <sliding> will contain at least as many elements as <base>.

Multiply each element in <base> by its corresponding element in sliding: <base>[0] * <sliding>[0], <base>[1] * <sliding>[1], <base>[2] * <sliding>[2] and so on.

Add up the results of the above. Store this as your first answer, <answers>[0].

Do it again, but start one element further along in the sliding list. <base>[0] * <sliding>[1], <base>[1] * <sliding>[2], <base>[2] * <sliding>[3] and so on.

Add up the results of the above. Store this as your second answer, <answers>[1].

Repeat as many times as you can, storing each answer. You cannot go past the point where <sliding> has fewer elements than <base>.

EXTRA MERIT CHALLENGE: Solve in ONE LINE return statement! I already have a one-line solution to this so attempt and lets compare results. See the attached picture for more clarification

cc ndizzy, waali, 4kings, lexaydfg, Ihinmi and co

(1) (2) (3) ... (8) (9) (10) (11) (12) (13) (14) (Reply)

Meet Emmanuella Mayaki: Hired By A School In The UK As Coding Instructor / Build A JAMB Result Checking Website To Win 150,000 Naira / Meet Dare Obasanjo Who Works With Microsoft

(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. 102
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.