<jupyter_start><jupyter_text>String functions   str.count()<jupyter_code># The count() method returns the number of times a specified value appears in the string.
# return the number of times the value "apple" appears in the string:
"i love apple, apple is good food, i like apple juice.".count("apple")<jupyter_output><empty_output><jupyter_text>capitalize() : Converts first character to Capital Letter<jupyter_code>"i love apple, apple is good food, i like apple juice.".capitalize()
"i love apple. apple is good food. i like apple juice.".capitalize()
# center()
# center() Method With Default fillchar
"Python is great".center(30)
# center() Method With * fillchar
"Python is great".center(30, '*')
# endswith 
# The endswith() method returns True if a string ends with the specified suffix. If not, it returns False
# 1. endswith() Without start and end Parameters
text = "Python is easy to learn."

result = text.endswith('to learn')
# returns False
print(result)

result = text.endswith('to learn.')
# returns True
print(result)

result = text.endswith('Python is easy to learn.')
# returns True
print(result)
# 1. endswith() With start and end Parameters
text = "Python programming is easy to learn."

# start parameter: 7
# "programming is easy to learn." string is searched
result = text.endswith('learn.', 7)
print(result)

# Both start and end is provided
# start: 7, end: 26
# "programming is easy" string is searched

result = text.endswith('is', 7, 26)
# Returns False
print(result)

result = text.endswith('easy', 7, 26)
# returns True
print(result)
# isalnum() characters + numbers + no spaces + no comma + no dot+ no special characters
"150".isalnum()
"Python".isalnum()
"Python36".isalnum()
"python%&36".isalnum()
# some practical example with string.isalnum()
if("I like apple. Apple is the best fruit for health. Apple Juice is delicious".isalnum()==True):
    print("string is alpha-numerical")
else:
    print("string contains some special characters")
if("I like apple Apple is the best fruit for health Apple Juice is delicious".isalnum()==True):
    print("string is alpha-numerical")
else:
    print("string contains some special characters")
if("I like apple5 Apple is the best fruit for health5 Apple Juice is delicious".isalnum()==True):
    print("string is alpha-numerical")
else:
    print("string contains some special characters")
"".join("I like apple5 Apple is the best fruit for health5 Apple Juice is delicious".split())
"Ilikeapple5Appleisthebestfruitforhealth5AppleJuiceisdelicious".isalnum()
if("IlikeappleAppleisthebestfruitforhealthAppleJuiceisdelicious".isalnum() == True):
     print("string is alpha-numerical")
else:
    print("string contains some special characters")
# string isalpha()
"Penan".isalpha()
"Penan ".isalpha()
"454854".isalpha()
"jdfj565".isalpha()
# isnumeric()
"447".isnumeric()
"56485 ".isnumeric()
"65649a".isnumeric()
# isdigit()
"6264650".isdigit()
# isspace()
spaced = "hdash hdjuasud 565"
spaced.isspace()
" ".isspace()
"  \t".isspace()
"  ".isspace()
if(input().isspace() == True ):
    print("You should not enter white spaces")
else:
    print("you entered text")
if(input().isspace() == True ):
    print("You should not enter white spaces")
else:
    print("you entered text")
# title()
"apple is most trusted brand in the world".title()
# istitle() 
# checks for titlecase
# apple is best pc => titlecase => Apple Is My Best Pc
"apple is most trusted brand".istitle()
"Apple is most trusted brand".istitle()
"Apple is most trusted brand".istitle()
s = 'Python Is Good.'
print(s.istitle())

s = 'Python is good'
print(s.istitle())

s = 'This Is @ Symbol.'
print(s.istitle())

s = '99 Is A Number'
print(s.istitle())

s = 'PYTHON'
print(s.istitle())
# bool()   isbool()
# title()  istitle()
# lower()  islower()
# upper()  isupper()
# strip()
# lstrip()
# rstrip()
# join()
bool("True")
bool("nasdjas")
bool("15156")
test = []
print(test,'is',bool(test))

test = [0]
print(test,'is',bool(test))

test = 0.0
print(test,'is',bool(test))

test = None
print(test,'is',bool(test))

test = True
print(test,'is',bool(test))

test = 'Easy string'
print(test,'is',bool(test))
# string.join(iterable)
"/".(" asnfjansdja bndajs d asdmakdnak ndaspi")
# itearable is list here
var = ["Penan", "Rajput", "Programmer"]
"/".join(var)
", ".join(var)
type(", ".join(var))
type(var)
float("4213.12312")
# converts to 
# Its like TYPECAST
# int() 
# float()
# complex()
# bool()
int("53sda")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1498436802143814, 'fraction_numerical': 0.018535060294774454, 'mean_word_length': 5.152472527472527, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '197611', 'license': 'MIT', 'n_tokens_mistral': 1551, 'n_tokens_neox': 1463, 'n_words': 484, 'path': '03. String Handling/.ipynb_checkpoints/2. String Functions, Methods-checkpoint.ipynb', 'repo_name': 'penanrajput/PythonCourseContent', 'size': '4478'}