STRINGS:
In Python, a string is a sequence of characters enclosed within single, double, or triple quotes. Strings are a fundamental data type in Python, and they are used extensively for storing and manipulating textual data.
Here are some basic operations that can be performed on strings in Python:
Here are some examples:
# Concatenation
greeting = "Hello "
name = "Alice"
message = greeting + name
print(message) # Output: "Hello Alice"
# Indexing and Slicing
my_string = "Python is cool"
print(my_string[0]) # Output: "P"
print(my_string[7:9]) # Output: "is"
print(my_string[-4:]) # Output: "cool"
# Length
my_string = "Hello World!"
print(len(my_string)) # Output: 12
# String Methods
my_string = "Hello World!"
print(my_string.upper()) # Output: "HELLO WORLD!"
print(my_string.replace("Hello", "Hi")) # Output: "Hi World!"
Learners TV is a website that is designed to educate users and provide instructional material on particular subjects and topics.