[Tutor] Need Help!

Mats Wichmann mats at wichmann.us
Sat Oct 19 18:39:29 EDT 2019


On 10/19/19 5:02 AM, Ronald Walker via Tutor wrote:
> I am uninitiated with computers and with computer speak.
> 
> I would very much appreciate some help at a primary level.
> 
> I am trying to learn Python because most of the research I did on
> programming languages suggest that Python is supposed to be quite easy to
> learn. However, in reading Python materials it seems to assume that I know
> what they are talking about and am familiar with the jargon and many other
> matters.

that's correct.  reference materials (typically) use a concise dialect 
which attempts to be quite precise but is oriented to the experienced 
user.  the dialect uses English words as well as a certain "well known" 
symbology, but it could never be mistaken for conversational English. 
You will want to learn to program from other materials, then when you're 
familiar will find that going back to the reference materials (in 
Python's case online language and standard library documents and the 
interactive help) will clear up specific points you might have been 
unclear on quite well. The tutorial in the python.org documentation is 
more accessible, but is not written for non-programmers, in fact it 
spends time referencing some concepts from what I find to be rather 
obscure programming languages...

> Help on method_descriptor:
>  
> count(...)
>      S.count(sub[, start[, end]]) -> int
> 
>      Return the number of non-overlapping occurrences of substring sub in
>      string S[start:end].  Optional arguments start and end are
>      interpreted as in slice notation.
> 

> What does
> 
> S.count(sub[,start[, end[]] -> int
> 
> Mean?

As I said, you don't want to be doing your initial learning from this, 
but since you ask:

given a string 'S', if you call the 'count' method on it (S.count), you 
are to give it 'sub', the substring to count the occurrences of. 
Optionally you may give a starting position in S to begin this 
search-and-count operation, and if you do then you also have the option 
to give an ending position.  The method returns (->) an integer count.

> What does
> 
> Return the number of non-overlapping occurrences of substring sub in
>      string S[start:end].  Optional arguments start and end are
>      interpreted as in slice notation.
> 
> Mean?

it means you count how many times the substring occurs, but you ignore 
cases where occurrences overlap. "Slice notation" is something that will 
become familiar to you fairly soon, but you should not expect to know 
what it is now. Testing this out this interactively:

 >>> S = "This description is caca.  In fact you might call it cacacaca."
 >>> S.count('caca')
3

the word at the end 'cacacaca' is back-to-back instances of caca, thus 
counts two - you can see there's a case of overlap and one might say if 
you look independently that the substring occurs three times in it, but 
the text of the help message tells you it won't count it that way. if in 
doubt: try it out, that's one of the real benefits of an interactive 
interpreted language - it's really cheap to experiment, so if you find a 
description unclear, just try it out.

> It is English. And I am quite literate in English. But this English is not
> using English vocabulary and syntax in a way that I can semantically
> understand.

as noted above.


> I want to find some actual concrete Python code from an actual working
> program that explains what all this means!

you can find interesting code examples at ProgramCreek here:

https://www.programcreek.com/python/

however they are unannotated and basics like this one are hard to 
construct a match for.  there are many many websites which do show 
Python interfaces and examples.

There are a number of resources for non-programmers.  Some are listed on 
the Python wiki, which since it depends on user contributions, is never 
complete, but nonetheless worth a look:

https://wiki.python.org/moin/BeginnersGuide/NonProgrammers

I might particularly mention the Learn to Program website and materials 
by Alan Gauld, who is a very frequent contributor here:

http://www.alan-g.me.uk/l2p/index.htm



More information about the Tutor mailing list