Python for beginners/some vocabulary
Other pages: Python for Beginners // Loops and Conditions // Create anthology
- A string or string object is a MODULE in Python
- A MODULE is a file, which contains Python statements.
Normally among these there are:
- definition statements - the execution of the module defines some functions
- class statements - the execution of the module defines some classes.
A module may also contain names (variables) and other directly executable Python statements.
- you can write your own definitions/functions and save them I a file that you can import into another python-file
- such a document is an external module, called at the beginning of a script using 'import name_module'
- CLASSES contain METHODS, a series of FUNCTIONS that belong to an object
The string-module contains classes with functions that allow you to calculate the length of the string, slice etc
- Anything in Python can be an OBJECT, because it can be assigned to a variable or can be an argument (input) for a function - see also OBJECT ORIENTED PROGRAMMING
- An ATTRIBUTE is is a way to move from one object to the other
“Apply the power of the almighty dot” - objectname.method(attributename) – and magic!
Note: to know the methods of an object: dir()
dir() prints the list of attributes
>>> sentence = "This is so exciting!"
>>> suffix = "ing!"
- Exercise: think of formula that gives TRUE for suffix 'is'
Note: a long string can be annotated using 3 """ a lot of words """
If you have a very long string, you better use:
very_long_string = (
"For a long time I used to go to bed early." "There was no one in the house. Etc etc …."