Some in-built functions that can make your task of working around strings a cakewalk!
Thread π§΅
βοΈ What are STRINGS?
In Python, there is no character! Even a single character is considered a string. Strings are an immutable sequence.
Immutable -> Once strings are created, they cannot be changed.
So, you can't change the string, but the reference to it can be changed.
βοΈ .split()
a = "this is a string"
a.split()
O/P: ['this', 'is', 'a', 'string']
The string is split into each word in the sentence, considering the DELIMITER as space. The output of the split function is given in a LIST.
DELIMITER -> It is a character or a group of characters that describe how to split the string.
For eg:
a = "this is a string"
a.split("is")
## In the bracket, we defined the delimiter as 'is'}
O/P: ['th', ' ', ' a string']
βοΈ .replace()
This is used to replace a character or a group of characters with another.
a = "this is a string"
a.replace("this", "that")
O/P: 'that is a string'
The word 'this' is replaced with 'that'.
βοΈ .strip()
This function returns a copy of the string in which all the characters have been removed (stripped) from the beginning and the end of the string.
For eg:
a = "I am Sukriti. I am a learner. Who am I"
a.strip('I')
O/P: am Sukriti. I am a learner. Who am
Notice that the .strip() method removed the 'I' only from the beginning and the end.
If no argument is passed to the method, it removes blank spaces from the beginning and the end by default.
βοΈ .find()
It returns the index value for the first occurrence of the passed value in the method.
For eg:
a = "I am Sukriti. I am a learner. Who am I"
a.find('learner')
O/P: 21
The word 'learner' begins from index 21.
Note: The beginning value of the index is zero (0).
To verify:-
a = "I am Sukriti. I am a learner. Who am I"
a.find('I')
O/P: 0
Since the occurrence of the first 'I' is at the beginning, so .find() must return the answer as 0. Hence we got the output as 0.
β’ β’ β’
Missing some Tweet in this thread? You can try to
force a refresh
The topic of TRIGGERS is a level-up from creating queries and sub-queries in the handling databases.
A super-easy guide to triggers in SQL π§΅π
βοΈ What is a trigger in the laymen (standard) language?
When someone pokes you or does something to agitate you, there is a high chance that you might get 'triggered' automatically! Right?
βοΈ Triggers in SQL
So, when we say TRIGGERS in SQL, it is simply a stored program that gets executed on its own when a triggering event occurs. Now, triggers are a part of PL/SQL.
PL/SQL is an extension of SQL where SQL queries are used and procedural statements/language.
A Beginner-friendly version of SQL (UPDATE and DELETE)
π§΅π
π Let's look at the table first!
The name of the table is -> faculties
We have columns as FacultyId, Name, Class, EmailId and Salary.
βοΈ UPDATE
This clause is used to change values in a specified column.
You may or may not provide a condition along with the change you want to make.
π Update without condition:-
UPDATE table_name SET column_name = column_value;
SQL - A Beginner-friendly version! π
(Clauses: IN, BETWEEN and LIKE)
Thread π§΅
πWhich table are we working on today?
The name of the table is "products". So the columns that we have are productCode, productName, productDescription, among others.
Take a look π
βοΈ IN
This clause would reduce the efforts to write multiple OR conditions. It helps you find a specific match for a value.
π select column1, column2 from table_name where EXPRESSION IN ('value1', 'value2')
Here is another thread of the most important clauses to boost your SQL queries to the next level!
Advance SQL, A beginner-friendly version! (#DataScience)
Thread π§΅
Let me explain what the table looks like.
The table name is customer_list, where the columns are ID, name, address, zip code, phone, city, country, notes & SID.
See the image for reference
βοΈ GROUP BY
This clause is used to group rows that have the same values together. It summarises data from the database.
Note: The group by clause returns one row for each group.
π Query: select col_name from table_name GROUP BY column_name;