The document discusses Python regular expressions (RegEx). It covers importing the re module, using common RegEx functions like search(), findall(), split(), and sub(). It also covers RegEx patterns like metacharacters, special sequences, and match objects. Named groups are introduced as a way to make RegEx matches more readable by labeling parts of the pattern instead of using numbers.
Regular expressions are used to identify whether a pattern exists in a given sequence of characters (string) or not. They help in manipulating textual data, which is often a pre-requisite for data science projects that involve text mining. You must have come across some application of regular expressions: they are used at the server side to validate the format of email addresses or password during registration, used for parsing text data files to find, replace or delete certain string, etc.
2D array in C++ language ,define the concept of c++ Two-Dimensional array .with example .and also Accessing Array Components concept.and Processing Two-Dimensional Arrays.
Regular expressions are used to identify whether a pattern exists in a given sequence of characters (string) or not. They help in manipulating textual data, which is often a pre-requisite for data science projects that involve text mining. You must have come across some application of regular expressions: they are used at the server side to validate the format of email addresses or password during registration, used for parsing text data files to find, replace or delete certain string, etc.
2D array in C++ language ,define the concept of c++ Two-Dimensional array .with example .and also Accessing Array Components concept.and Processing Two-Dimensional Arrays.
This presentation is all about various built in
datastructures which we have in python.
List
Dictionary
Tuple
Set
and various methods present in each data structure
PYTHON-Chapter 3-Classes and Object-oriented Programming: MAULIK BORSANIYAMaulik Borsaniya
Classes and Object-oriented Programming:
Classes: Creating a Class, The Self Variable, Constructor, Types of Variables, Namespaces, Types of Methods (Instance Methods, Class Methods, Static Methods), Passing Members of One Class to Another Class, Inner Classes
Inheritance and Polymorphism: Constructors in Inheritance, Overriding Super Class Constructors and Methods, The super() Method, Types of Inheritance, Single Inheritance, Multiple Inheritance, Method Resolution Order (MRO), Polymorphism, Duck Typing Philosophy of Python, Operator Overloading, Method Overloading, Method Overriding
Abstract Classes and Interfaces: Abstract Method and Abstract Class, Interfaces in Python, Abstract Classes vs. Interfaces,
All data values in Python are encapsulated in relevant object classes. Everything in Python is an object and every object has an identity, a type, and a value. Like another object-oriented language such as Java or C++, there are several data types which are built into Python. Extension modules which are written in C, Java, or other languages can define additional types.
To determine a variable's type in Python you can use the type() function. The value of some objects can be changed. Objects whose value can be changed are called mutable and objects whose value is unchangeable (once they are created) are called immutable.
Object oriented programming with pythonArslan Arshad
A short intro to how Object Oriented Paradigm work in Python Programming language. This presentation created for beginner like bachelor student of Computer Science.
This presentation is all about various built in
datastructures which we have in python.
List
Dictionary
Tuple
Set
and various methods present in each data structure
PYTHON-Chapter 3-Classes and Object-oriented Programming: MAULIK BORSANIYAMaulik Borsaniya
Classes and Object-oriented Programming:
Classes: Creating a Class, The Self Variable, Constructor, Types of Variables, Namespaces, Types of Methods (Instance Methods, Class Methods, Static Methods), Passing Members of One Class to Another Class, Inner Classes
Inheritance and Polymorphism: Constructors in Inheritance, Overriding Super Class Constructors and Methods, The super() Method, Types of Inheritance, Single Inheritance, Multiple Inheritance, Method Resolution Order (MRO), Polymorphism, Duck Typing Philosophy of Python, Operator Overloading, Method Overloading, Method Overriding
Abstract Classes and Interfaces: Abstract Method and Abstract Class, Interfaces in Python, Abstract Classes vs. Interfaces,
All data values in Python are encapsulated in relevant object classes. Everything in Python is an object and every object has an identity, a type, and a value. Like another object-oriented language such as Java or C++, there are several data types which are built into Python. Extension modules which are written in C, Java, or other languages can define additional types.
To determine a variable's type in Python you can use the type() function. The value of some objects can be changed. Objects whose value can be changed are called mutable and objects whose value is unchangeable (once they are created) are called immutable.
Object oriented programming with pythonArslan Arshad
A short intro to how Object Oriented Paradigm work in Python Programming language. This presentation created for beginner like bachelor student of Computer Science.
I am Charles B. I am an Algorithm Assignment Expert at programminghomeworkhelp.com. I hold a Ph.D. in Programming, Texas University, USA. I have been helping students with their homework for the past 6 years. I solve assignments related to Algorithms.
Visit programminghomeworkhelp.com or email support@programminghomeworkhelp.com.You can also call on +1 678 648 4277 for any assistance with Algorithm assignments.
Homework Assignment – Array Technical DocumentWrite a technical .pdfaroraopticals15
Homework Assignment – Array Technical Document
Write a technical document that describes the structure and use of arrays. The document should
be 3 to 5 pages and include an Introduction section, giving a brief synopsis of the document and
arrays, a Body section, describing arrays and giving an annotated example of their use as a
programming construct, and a conclusion to revisit important information about arrays described
in the Body of the document. Some suggested material to include:
Declaring arrays of various types
Array pointers
Printing and processing arrays
Sorting and searching arrays
Multidimensional arrays
Indexing arrays of various dimension
Array representation in memory by data type
Passing arrays as arguments
If you find any useful images on the Internet, you can use them as long as you cite the source in
end notes.
Solution
Array is a collection of variables of the same type that are referenced by a common name.
Specific elements or variables in the array are accessed by means of index into the array.
If taking about C, In C all arrays consist of contiguous memory locations. The lowest address
corresponds to the first element in the array while the largest address corresponds to the last
element in the array.
C supports both single and multi-dimensional arrays.
1) Single Dimension Arrays:-
Syntax:- type var_name[size];
where type is the type of each element in the array, var_name is any valid identifier, and size is
the number of elements in the array which has to be a constant value.
*Array always use zero as index to first element.
The valid indices for array above are 0 .. 4, i.e. 0 .. number of elements - 1
For Example :- To load an array with values 0 .. 99
int x[100] ;
int i ;
for ( i = 0; i < 100; i++ )
x[i] = i ;
To determine to size of an array at run time the sizeof operator is used. This returns the size in
bytes of its argument. The name of the array is given as the operand
size_of_array = sizeof ( array_name ) ;
2) Initialisg array:-
Arrays can be initialised at time of declaration in the following manner.
type array[ size ] = { value list };
For Example :-
int i[5] = {1, 2, 3, 4, 5 } ;
i[0] = 1, i[1] = 2, etc.
The size specification in the declaration may be omitted which causes the compiler to count the
number of elements in the value list and allocate appropriate storage.
For Example :- int i[ ] = { 1, 2, 3, 4, 5 } ;
3) Multidimensional array:-
Multidimensional arrays of any dimension are possible in C but in practice only two or three
dimensional arrays are workable. The most common multidimensional array is a two
dimensional array for example the computer display, board games, a mathematical matrix etc.
Syntax :type name [ rows ] [ columns ] ;
For Example :- 2D array of dimension 2 X 3.
int d[ 2 ] [ 3 ] ;
A two dimensional array is actually an array of arrays, in the above case an array of two integer
arrays (the rows) each with three elements, and is stored row-wise in memory.
For Example :- Program to fill .
I am Arnold H. I am a C++ Programming Homework Expert at cpphomeworkhelp.com. I hold a Masters in Programming from The University of Sheffield, UK. I have been helping students with their homework for the past 6 years. I solve homework related to C++ Programming.
Visit cpphomeworkhelp.com or email info@cpphomeworkhelp.com. You can also call on +1 678 648 4277 for any assistance with C++ Programming Homework.
Python- Creating Dictionary,
Accessing and Modifying key: value Pairs in Dictionaries
Built-In Functions used on Dictionaries,
Dictionary Methods
Removing items from dictionary
Ethnobotany and Ethnopharmacology:
Ethnobotany in herbal drug evaluation,
Impact of Ethnobotany in traditional medicine,
New development in herbals,
Bio-prospecting tools for drug discovery,
Role of Ethnopharmacology in drug evaluation,
Reverse Pharmacology.
2024.06.01 Introducing a competency framework for languag learning materials ...Sandy Millin
http://sandymillin.wordpress.com/iateflwebinar2024
Published classroom materials form the basis of syllabuses, drive teacher professional development, and have a potentially huge influence on learners, teachers and education systems. All teachers also create their own materials, whether a few sentences on a blackboard, a highly-structured fully-realised online course, or anything in between. Despite this, the knowledge and skills needed to create effective language learning materials are rarely part of teacher training, and are mostly learnt by trial and error.
Knowledge and skills frameworks, generally called competency frameworks, for ELT teachers, trainers and managers have existed for a few years now. However, until I created one for my MA dissertation, there wasn’t one drawing together what we need to know and do to be able to effectively produce language learning materials.
This webinar will introduce you to my framework, highlighting the key competencies I identified from my research. It will also show how anybody involved in language teaching (any language, not just English!), teacher training, managing schools or developing language learning materials can benefit from using the framework.
We all have good and bad thoughts from time to time and situation to situation. We are bombarded daily with spiraling thoughts(both negative and positive) creating all-consuming feel , making us difficult to manage with associated suffering. Good thoughts are like our Mob Signal (Positive thought) amidst noise(negative thought) in the atmosphere. Negative thoughts like noise outweigh positive thoughts. These thoughts often create unwanted confusion, trouble, stress and frustration in our mind as well as chaos in our physical world. Negative thoughts are also known as “distorted thinking”.
The French Revolution, which began in 1789, was a period of radical social and political upheaval in France. It marked the decline of absolute monarchies, the rise of secular and democratic republics, and the eventual rise of Napoleon Bonaparte. This revolutionary period is crucial in understanding the transition from feudalism to modernity in Europe.
For more information, visit-www.vavaclasses.com
Instructions for Submissions thorugh G- Classroom.pptxJheel Barad
This presentation provides a briefing on how to upload submissions and documents in Google Classroom. It was prepared as part of an orientation for new Sainik School in-service teacher trainees. As a training officer, my goal is to ensure that you are comfortable and proficient with this essential tool for managing assignments and fostering student engagement.
How to Create Map Views in the Odoo 17 ERPCeline George
The map views are useful for providing a geographical representation of data. They allow users to visualize and analyze the data in a more intuitive manner.
2. Python RegEx
• A RegEx, or Regular Expression, is a sequence of characters that forms a
search pattern.
• RegEx can be used to check if a string contains the specified search pattern.
RegEx Module
• Python has a built-in package called re, which can be used to work with
Regular Expressions.
• Import the re module:
import re
06-04-2022 meghav@kannuruniv.ac.in 2
3. RegEx in Python
• When you have imported the re module, you can start using regular
expressions:
Example
• Search the string to see if it starts with "The" and ends with "Spain":
import re
txt = "The rain in Spain"
x = re.search("^The.*Spain$", txt)
06-04-2022 meghav@kannuruniv.ac.in 3
4. RegEx Functions
• The re module offers a set of functions that allows us to search a
string for a match:
Function Description
findall Returns a list containing all matches
search Returns a Match object if there is a match anywhere in the string
split Returns a list where the string has been split at each match
sub Replaces one or many matches with a string
06-04-2022 meghav@kannuruniv.ac.in 4
5. Metacharacters
• Metacharacters are characters with a special meaning:
Character Description Example
[] A set of characters "[a-m]"
Signals a special sequence (can also be used
to escape special characters)
"d"
. Any character (except newline character) "he..o"
^ Starts with "^hello"
$ Ends with "planet$"
* Zero or more occurrences "he.*o"
+ One or more occurrences "he.+o"
? Zero or one occurrences "he.?o"
{} Exactly the specified number of occurrences "he{2}o"
| Either or "falls|stays"
() Capture and group
06-04-2022 meghav@kannuruniv.ac.in 5
6. Special Sequences
• A special sequence is a followed by one of the characters in the list below, and has a special
meaning:
Character Description Example
A Returns a match if the specified characters are at the beginning of the string "AThe"
b Returns a match where the specified characters are at the beginning or at the end of a
word
(the "r" in the beginning is making sure that the string is being treated as a "raw string")
r"bain"
r"ainb"
B Returns a match where the specified characters are present, but NOT at the beginning (or
at the end) of a word
(the "r" in the beginning is making sure that the string is being treated as a "raw string")
r"Bain"
r"ainB"
d Returns a match where the string contains digits (numbers from 0-9) "d"
D Returns a match where the string DOES NOT contain digits "D"
s Returns a match where the string contains a white space character "s"
S Returns a match where the string DOES NOT contain a white space character "S"
w Returns a match where the string contains any word characters (characters from a to Z,
digits from 0-9, and the underscore _ character)
"w"
W Returns a match where the string DOES NOT contain any word characters "W"
Z Returns a match if the specified characters are at the end of the string "SpainZ"
06-04-2022 meghav@kannuruniv.ac.in 6
7. The findall() Function
• The findall() function returns a list containing all matches.
Example
• Print a list of all matches:
import re
txt = "The rain in Spain"
x = re.findall("ai", txt)
print(x) #['ai', 'ai']
• The list contains the matches in the order they are found.
• If no matches are found, an empty list is returned:
06-04-2022 meghav@kannuruniv.ac.in 7
8. • Example
• Return an empty list if no match was found:
import re
txt = "The rain in Spain"
x = re.findall("Portugal", txt)
print(x) #[ ]
06-04-2022 meghav@kannuruniv.ac.in 8
9. The search() Function
• The search() function searches the string for a match, and returns a
Match object if there is a match.
• If there is more than one match, only the first occurrence of the
match will be returned:
06-04-2022 meghav@kannuruniv.ac.in 9
10. Example
• Search for the first white-space character in the string:
import re
txt = "The rain in Spain"
x = re.search("s", txt)
print("The first white-space character is located in position:", x.start())
• If no matches are found, the value None is returned:
06-04-2022 meghav@kannuruniv.ac.in 10
11. Example
• Make a search that returns no match:
import re
txt = "The rain in Spain"
x = re.search("Portugal", txt)
print(x)
06-04-2022 meghav@kannuruniv.ac.in 11
12. The split() Function
• The split() function returns a list where the string has been split at each
match:
Example
• Split at each white-space character:
import re
txt = "The rain in Spain"
x = re.split("s", txt)
print(x)
• You can control the number of occurrences by specifying the maxsplit
parameter:
06-04-2022 meghav@kannuruniv.ac.in 12
13. Example
•Split the string only at the first occurrence:
import re
txt = "The rain in Spain"
x = re.split("s", txt, 1)
print(x)
06-04-2022 meghav@kannuruniv.ac.in 13
14. The sub() Function
• The sub() function replaces the matches with the text of your choice:
Example
• Replace every white-space character with the number 9:
import re
txt = "The rain in Spain"
x = re.sub("s", "9", txt)
print(x)
• You can control the number of replacements by specifying the count
parameter:
06-04-2022 meghav@kannuruniv.ac.in 14
15. Example
• Replace the first 2 occurrences:
import re
txt = "The rain in Spain"
x = re.sub("s", "9", txt, 2)
print(x)
06-04-2022 meghav@kannuruniv.ac.in 15
16. Match Object
• A Match Object is an object containing information about the search
and the result.
• Note: If there is no match, the value None will be returned, instead of
the Match Object.
06-04-2022 meghav@kannuruniv.ac.in 16
17. Example
• Do a search that will return a Match Object:
import re
txt = "The rain in Spain"
x = re.search("ai", txt)
print(x) #this will print an object
Output
<re.Match object; span=(5, 7), match='ai'>
06-04-2022 meghav@kannuruniv.ac.in 17
18. • The Match object has properties and methods used to
retrieve information about the search, and the result:
.span() -returns a tuple containing the start-, and end
positions of the match.
.string- returns the string passed into the function
.group()-returns the part of the string where there
was a match
06-04-2022 meghav@kannuruniv.ac.in 18
19. Example
• Print the position (start- and end-position) of the first match
occurrence.
• The regular expression looks for any words that starts with an upper
case "S":
import re
txt = "The rain in Spain"
x = re.search(r"bSw+", txt)
print(x.span()) # (12, 17)
06-04-2022 meghav@kannuruniv.ac.in 19
20. Example
• Print the string passed into the function:
import re
txt = "The rain in Spain"
x = re.search(r"bSw+", txt)
print(x.string)
Output
The rain in Spain
06-04-2022 meghav@kannuruniv.ac.in 20
21. Example
• Print the part of the string where there was a match.
• The regular expression looks for any words that starts with an upper
case "S":
import re
txt = "The rain in Spain"
x = re.search(r"bSw+", txt)
print(x.group()) #Spain
06-04-2022 meghav@kannuruniv.ac.in 21
22. Named Groups with Regular Expressions
• Groups are used in Python in order to reference regular expression
matches.
• By default, groups, without names, are referenced according to
numerical order starting with 1 .
• Let's say we have a regular expression that has 3 subexpressions.
• A user enters in his birthdate, according to the month, day, and year.
• Let's say the user must first enter the month, then the day, and then the
year.
06-04-2022 meghav@kannuruniv.ac.in 22
23. Named Groups with Regular Expressions
• Using the group() function in Python, without named groups, the first
match (the month) would be referenced using the statement, group(1).
• The second match (the day) would be referenced using the statement,
group(2).
• The third match (the year) would be referenced using the statement,
group(3).
06-04-2022 meghav@kannuruniv.ac.in 23
24. Named Groups with Regular Expressions
• Now, with named groups, we can name each match in the regular
expression.
• So instead of referencing matches of the regular expression with numbers
(group(1), group(2), etc.), we can reference matches with names, such as
group('month'), group('day'), group('year').
• Named groups makes the code more organized and more readable.
06-04-2022 meghav@kannuruniv.ac.in 24
25. Named Groups with Regular Expressions
• By seeing, group(1), you don't really know what this represents.
• But if you see, group('month') or group('year'), you know it's referencing
the month or the year.
• So named groups makes code more readable and more understandable
rather than the default numerical referencing.
06-04-2022 meghav@kannuruniv.ac.in 25