String Methods in Python | Python Tutorial - Day #13

preview_player
Показать описание
Python is one of the most demanded programming languages in the job market. Surprisingly, it is equally easy to learn and master Python. This python tutorial for absolute beginners in Hindi series will focus on teaching you python concepts from the ground up.

python, C, C++, Java, JavaScript and Other Cheetsheets [++]:

►Learn in One Video[++]:

►Complete course [playlist]:

Follow Me On Social Media
Comment "#HarryBhai" if you read this 😉😉
Рекомендации по теме
Комментарии
Автор

1. strings are immutable.
2. any method on string takes a copy of the object.
3.string.upper will convert the string to an upper case
4.string.lower will convert the string to lower case
5. string.rstrip("character") will strip the trailing characters of string
6.string.replace("character/alphabets", new character/alphabets") will replace the existing specified alphabets in string with new ones
7. string.split splits the string at the given alphabet and returns a list of items
8.string.capitalize capitalizes the first character of the word and turns rest all the characters to lower case
9.string.center center aligns the string by adding the number of spaces mentioned in parenthesis
10. string.count counts the total number of a particular set of characters in a string
11. string.endswith checks whether a string ends with the specific characters
12.string.find finds the first occurrence of a given value and return the index value of the position of that occurrence
13.string.index finds the occurrence of a given value and returns the index value of the position however, if it is unable to find it will give an error causing the program to exit
14.string.isalnum checks to find if string is alphanumeric and returns true or false
15.string.isalpha checks if there are any numbers in the string
16.string.islower checks if there are only lower aphabets in the string
17. string.isprintable checks if all the characters are printable in the string(non printable characters e.g \n)
18 string.isspace checks if any space bar has been used in the string
19.string.istitle The istitile() returns True only if the first letter of each word of the string is capitalized, else 20. string.isupper checks if all characters are uppercase in a string
21. string.startswith checks if a string starts with a given value
22. string.swapcase convert uppercase to lowercase and vice versa in a string
23.string.title converts first character of all the words in the sentence to capital

sohailnawaz
Автор

Ready with Harry bhai.... For day 13

It is the first time when I stood constant with any series on youtube or Netflix.... Salute to Harry bhai...

HashimKhan-mtpp
Автор

1-- upper()
2-- lower()
3-- rstrip()
4-- replace("find", "replace")
5-- split (" ")
6-- capitalize()
7-- center()
8-- count()
9-- endswith()
10-- find()
11-- index()
12-- isalnum()
13-- isalpha()
14-- islower()
15-- isprintable()
16-- isspace()
17-- istitle()
18--startswith()
19-- swapcase()
20-- title()

bhau
Автор

Mobile phone me coding karne walo ke jazbe ko dil se salam. ❤️‍🔥🤝 don't give up keep trying

mohammadhuzaifaansari
Автор

Very best channels for study all programming langauge

tinkeshnikhare
Автор

Here are few more string methods which may be useful to someone:

1. casefold(): similar to lower() but more aggressive and strong.
2. encode(): return a encoded version of a string.
3. format(): format specific values inside the string.

FaceSenseAustralia
Автор

Note: If you are going though sentences, it counts space too. (for string slicing)

-PShreyanshKarna
Автор

'rstrip' function strips the character from right side and there is another command 'lstrips' which strips the character from left side and 'strip' function strips the character from anyside of the string

yashwantsingh
Автор

08:41
Bro you made things complex as you just printed the length of str1.center(50)
center function centers the string from both ends of the string
For instance:
You should give the example like this:
name = "Harry"
print(name.center(9), end=", ") # you can use any symbol instead of comma

This will be a good and unambiguous example.
This will show that 9-5=4 and 2 spaces will be given to start of the string and 2 at last and at the end of all comma will be printed.

I hope you will consider my suggestion.
I said it because my 2 friends are also watching the playlist and their concept was not cleared about center function.

TECHWIZARD
Автор

Man hats off, u r teaching for free and in a good quality too

dwarakeshsrao
Автор

# converting string into uppercase note: strings are immutable
a = "Harry"
print(len(a))
print(a.upper())
print(a.lower())

# one more example of upper() and lower() functions
str1 = "AbcDEfghIJ"
print(str1.upper())
print(str1.lower())

# using strip() function we can remove white spaces before and after string
str2 = " Silver Spoon "
print(str2.strip())

# rstrip() function used to remove any trailing characters
str3 = "Hello !!!"
print(str3.rstrip("!"))

# replace() method using which we can replace all occurences of string with another string
str2 = "Silver Spoon"
print(str2.replace("Sp", "m"))

# split() method splits the given string at the specified instance and returns the separated strings as list items.
str2 = "Silver Spoon"
print(str2.split(" "))

# capitalize() method is used to turn first character of string into uppercase and rest into lower case
str1 = "hello"
capStr1 = str1.capitalize()
print(capStr1)

str2 = "hello World"
capStr2 = str2.capitalize()
print(capStr2)

# using center() method to align the string to the center
str1 = "Welcome to the Console!!!"
print(str1.center(50))
# another example of center() method
str1 = "Welcome to the Console!!!"
print(str1.center(50, "."))

# count() method returns the number of times the given value has occured within the given string
str2 = "Abracadabra"
countStr = str2.count("a")
print(countStr)

# endswith() method checks if the string ends with a given value. If yes then return True, else return False.
str1 = "Welcome to the Console !!!"
print(str1.endswith("Console !!!"))
# another example of endswith() checking for a value in between the string by providing start and end index positions.
print(str1.endswith("to", 4, 10))

# find() method searches for the first occurrence of the given value and returns the index where it is present. If given value is absent from the string then return -1.
str1 = "He's name is Dan. He is an honest man."
print(str1.find("is"))
print(str1.find("Daniel"))

# index() method searches for the first occurrence of the given value and returns the index where it is present. If given value is absent from the string then raise an exception.
str1 = "He's name is Dan. Dan is an honest man."
print(str1.index("Dan"))
# print(str1.index("Daniel")) # this will show a value error

# isalnum() method returns True only if the entire string only consists of A-Z, a-z, 0-9. If any other characters or punctuations are present, then it returns false.
str1 = "WelcometoTheConsole"
print(str1.isalnum())

# isalpha() method returns True only if the entire string only consists of A-Z, a-z. If any other characters or punctuations or numbers(0-9) are present, then it returns false.
str1 = "Welcome"
print(str1.isalpha())

# islower() method returns True if all the characters in the string are lower case, else it returns false.
str1 = "hello world"
print(str1.islower())

# isprintable() method returns True if all the values within given string are printable, if not, then return False.
str1 = "We wish you a Merry Christmas"
print(str1.isprintable())
str1 = "We wish you a Merry Christmas\n"
print(str1.isprintable()) # this will return False

# isspace() method returns True only and only if the string contains white spaces, else returns False.
str1 = " " # using spacebar
print(str1.isspace())
str2 = " " # using Tab
print(str1.isspace())

# istitle() method returns True only if the first letter of each word of the string is capitalized, else it returns False
str1 = "World Health Organization"
print(str1.istitle())
str2 = "To kill a Mocking bird"
print(str2.istitle())

# isupper() method returns Ture if all the characters in the string are upper case, else it returns False.
str1 = "WORLD HEALTH ORGANIZATION"
print(str1.isupper())

# startswith() method checks if the string starts with a given value. If yes then return True, else return False.
str1 = "Python is a Interpreted Language"


# swapcase() method changes the character casing of the string. Upper case are converted to lower case and lower case to upper case.
str1 = "Python is a Interpreted Language"
print(str1.swapcase())

# title() method capitalizes first letter of each word within the string
str1 = "He's name is Dan. Dan is an honest man"
print(str1.title())

T.Akshay_Pratap_Singh
Автор

I have Python in my syllabus, I'm in 8th grade, I discovered this playlist a while ago, at first i decided to learn as much in my syllabus but after watching a few tutorials, I fell in love with Python and the teaching skills of CodeWithHarry sir and I am eager to learn more and complete this playlist.Thank you so much sir❤❤

dankrevvo
Автор

I am not able to find words to thank you for your kind efforts in teaching us very deeply u so much....jazak Allah😊

fatimaiqra
Автор

Harry bhaiya, I am late but speeding up and learning fast with your great explaination...we are lucky to have a teacher like you...Thank you😃

vivelafootball
Автор

mei to, harry bhai like karne ke liya aata hun, aur like kar ke chala jata hun, apke channel se java sikh raha hun ab, aur mera excitement badh raha he, apke channel se me sab sikhunga future mein.🙂👍🏻👍🏻👍🏻

badalsahoo
Автор

Koi itni mehnat kaisay kr skta hai aur wo bhi itni honesty k sath😇...Kamaal hai..Too much Impressive😍

Ayesha_
Автор

you are a brillient youtuber bro i feel like my own brother teaching me how to code.
love your

thomasshelby
Автор

100 days of python series >> any netflix series

prensudangol
Автор

Mind blowing explanation of each and every points sir.. Teaching technique is really a best and understandable..

ratndeepparmar
Автор

Day3 of #100DaysOfCode. Today in this video13, I learned about various string methods in Python, such as upper(), lower(), strip(), replace(), split(), and many others. These methods will help me manipulate strings effectively, such as changing character casing, aligning text, counting occurrences, and checking specific conditions within strings.
Thank You Harry Bhaiya.

debasishbesra