day #9- String_in_python

                   what is strings??



In python, anything that you enclose between single or double quotation marks is considered a string. A string is essentially a sequence or array of textual data. strings are used when working with unicode characters.

ex.

input-

name="hardik"

print("hello, "+name)

output- 

hello,hardk


name="hello world"

#sequence of the characters

print(name[0])

print(name[1])

print(name[2])

print(name[3])

print(name[4])

output-

h

e

e

l

o


case changing of python

1. lower():

 convert all uppercase characters in a string into lowercase.

2.upper():

converts all lowercase characters in a string into uppercase.

3.title():

convert string to title case

4.swapcase():

swap the cases of the characters in a string

5.capitalize():

convert the first characters of a string to uppercase

     input-


output-



List of string methods in python

6.casefold():

implements caseless string method

7.center():

pad the string with the specified character.

8.count():

return the number of occurrences of a substring in the string.

9.encode():

encodes strings with the specified encoded scheme.

10.endswith():

returns "True" if a string ends with the given suffix

11.expandtabs():

specifies the amount of space to be substituted with the '\t" symbol in the string.

12.find():

return the lowest index of the substring if it is found.

13.format():

formats the string for printing it to console.

14.format_map():

formats specified values in a string using a dictionary.

15.index():

returns the position of the first occurrence of a substring in a string.

16.isalnum():

checks whether all the characters in a given string is alphanumeric of not.

17.isalpha():

returns "True" if all characters in the string are alphabets.

18.isdecimal():

returns true if all characters in a string are decimal

19.isdecimal():

return true if all characters in a string are decimal.

20.isdigit():

return "True" if all characters in the string are digits.

21.isdentifier():

check whether a string is a valid identifier or not.

22.islower():

checks if all characters in the string are lowercase.

23.isnumeric():

return "True" if all characters in the string are printable or the string is empty.

24.isspace():

returns "True" if all characters in the string are whitespace characters.

25.istile():

returns "True" if the string is a title cased string.

26.isupper():

checks if all characters in the string are uppercase.

27.join():

returns a concatenated string.

28.ljust():

left aligns the string according to the width specified.

29.istrip():

returns the string with leading characters removed.

30.maketrans():

return  a translation table.

31.partition():

splits the string at the first occurrence of the separator.

32.replace():

replaces all occurrences if a substring with another substring.

33.rfind():

returns the highest index of the substring.

34.rindex():

returns the highest index of the substring inside the string.

35.rjust():

right aligns the string according to the width specified.

36.rstrip():

removes trailing characters

37.translate():

modify string according to given translation mappings.

38.zfill():

return a copy of the string with '0' characters padded to the left side of the stings.




Comments

Popular posts from this blog

day #6 - Exercise 1: make two Calculator using in python

day #5 - Operators in python