PYTHON STRINGS. Methods and slicing + practical tasks

Pubblicato il: 18 aprile 2023
sul canale di: Python Now
54
1

This video is a tutorial on using string methods and slicing in Python. The video explains what methods are, how to use them, and how to slice strings to extract specific parts of the text. The video covers commonly used string methods, including lower(), upper(), replace(), startswith(), endswith(), and split(). It also demonstrates how to use slicing to access specific characters or substrings from a string. The video includes practical examples and exercises to help viewers practice these concepts.

First video about strings:
   • Operations with STRINGS you should know in...   - watch it!

Practical tasks:

Task 1:
Create a string that contains the word "don't" and then use the split() method to split the string into two separate words.

Expected outcome: "I don't know" → ["I", "don't", "know"]

Task 2:
Create a string that contains a mix of uppercase and lowercase letters. Then use the title() method to convert the first letter of each word to uppercase.

Expected outcome: "harry potter and the goblet of fire" → "Harry Potter And The Goblet Of Fire"

Task 3:
Create a string that contains a sentence with multiple spaces between words. Then use the split() method with no arguments to split the sentence into a list of words without the extra spaces.

Expected outcome: " The quick brown fox " → ["The", "quick", "brown", "fox"]

Task 4:
Create a string that contains a sentence with a word repeated multiple times. Then use the replace() method to replace all instances of that word with a different word.

Expected outcome: "I love love love ice cream" → "I love adore adore ice cream"

#python #programming #strings


In questa pagina del sito puoi guardare il video online PYTHON STRINGS. Methods and slicing + practical tasks della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Python Now 18 aprile 2023, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 54 volte e gli è piaciuto 1 spettatori. Buona visione!