Basic String Operations & Concatenation
Basic string operation and manipulation techniques:
A string in Python is a sequence of characters (letters, numbers, symbols, or spaces) enclosed inside single (' '), double (" "), or triple (''' ''') quotes.
Basic String Operations:
Joining two or more strings end-to-end into a single string.
first = "Hello"
second = "Python"
result = first + " " + second
print(result)
A string is an immutable sequence of characters enclosed in quotes. Joining multiple strings is performed using the '+' operator.
String Repetition (*)
Repetition (*):
Repeating a string a specified number of times.
word = "Hi! "
print(word * 3)The '*' operator repeats a string a specified number of times efficiently without writing manual loops.
String Length Calculation (len())
Length (len()):
Returns the total number of characters in a string, including spaces.
text = "Python 101"
print(len(text))The len() function returns the total number of characters in a string, counting all spaces, letters, and punctuation.
String Indexing and Slicing Techniques
Indexing and Slicing
Accessing a single character using its position. Forward indexing starts at 0, while negative indexing starts at -1 from the end.
word = "PYTHON"
print(word[0])# First character
print(word[-1])# Last characterN
Slicing:
Extracting a substring (portion of a string) from start index up to stop - 1.
text = "Programming"
print(text[0:7])# Characters from index 0 to 6
print(text[:4])# From start up to index 3
print(text[::-1])# Reverses the entire stringProg
gnimmargorP
Forward indexing starts at 0, reverse indexing at -1. Slicing with [start:stop:step] extracts substrings without mutating the original string.
String Manipulation Methods (upper, lower, strip, replace, split, join)
String Manipulation Methods
Changing Case (upper(), lower(), title()):
Converts characters into uppercase, lowercase, or capitalizes the first letter of each word.
msg = "python programming"
print(msg.upper())
print(msg.title())Python Programming
Removing Whitespace (strip()):
Removes extra spaces (or specified characters) from the beginning and end of a string.
raw_input = " admin@gmail.com "
print(raw_input.strip())Replacing Text (replace(old, new)):
Replaces all occurrences of a specified substring with another substring.
text = "I like Java"
print(text.replace("Java","Python"))Splitting and Joining (split() & join()):
split() breaks a string into a list of substrings based on a separator, while join() combines a list of strings back into a single string.
data = "apple,banana,cherry"
fruits = data.split(",")# Splits into a list
print(fruits)
joined = " - ".join(fruits)# Joins list items into a string
print(joined)apple - banana – cherry
Built-in string methods like upper(), lower(), strip(), and split() return newly constructed string objects.
Python Standard Library Modules (math, os, datetime, sys)
Python Standard Library
It is a preinstalled default package that comes with Python, which can loaded using the import keyword.

math: Provides mathematical functions and constants like square roots, powers, and pi.
import math
print(math.sqrt(16))# Output: 4.0os: Interacts with your operating system to manage folders, file paths, and directories.
import os
print(os.getcwd())# Output: Current folder pathdatetime: Works with current dates, times, and calendar formatting.
import datetime
print(datetime.date.today())# Output: 2026-11-24sys: Accesses Python interpreter details and system-level settings.
import sys
print(sys.version)# Output: Installed Python versionThe Standard Library comes preinstalled with Python, offering battle-tested tools ready to use via the 'import' keyword.
Third-Party Libraries (NumPy, Pandas, Matplotlib, Flask, OpenCV)
Third-party libraries:
Third-party libraries are external packages and tools which is made by the global Python developer community. They are hosted on PyPI (Python Package Index) and installed using the pip install package_name command before importing them into your code.

Ex:
NumPy (Numerical Python): Used for fast mathematical operations, multi-dimensional arrays, and matrix calculations.
import numpyas np
arr = np.array([1, 2, 3])
print(arr * 2)# Output: [2 4 6]Pandas: Used for data analysis, cleaning, and manipulating tabular data (like Excel sheets or CSV files) using DataFrames.
import pandasas pd
df = pd.DataFrame({"Name": ["Aman", "Riya"], "Marks": [85, 92]})
print(df)Matplotlib: Used for creating static, animated, and interactive charts, graphs, and plots for data visualization.
import matplotlib.pyplotas plt
plt.plot([1, 2, 3], [4, 5, 6])
plt.show()Flask / Django: Web development frameworks used to build websites, web applications, and backend APIs.
from flask import Flask
app = Flask(__name__)
print("Flask app initialized:", app.name)OpenCV (cv2): Used for computer vision tasks like image processing, face detection, and video analysis.
import cv2
img = cv2.imread("photo.jpg")Third-party packages are created by the global Python community, hosted on PyPI, and installed using pip before importing.
Standard Library vs. Third-Party Library Comparison
Standard Library vs. Third-Party Library
| Feature | Standard Library | Third-Party Library |
|---|---|---|
| Installation | Already pre-installed with Python. | Must be installed separately via pip install. |
| Usage | Ready to import immediately. | import works only after installation. |
| Examples | math, random, datetime, os | numpy, pandas, matplotlib, requests |
Standard libraries are built-in and require no internet download; third-party packages must be downloaded from PyPI via pip install.
Installing and Uninstalling Libraries with pip
Installing and uninstalling libraries:
Python uses pip (Preferred Installer Program), It is a package manager, to download, install, update, and remove third-party libraries from the Python Package Index (PyPI).

Installing a Library
Downloads and adds a third-party library and its required dependencies to your Python environment so you can import it in your code.
pip install package_name
pip install numpyUninstalling a Library
Completely removes a previously installed third-party library from your Python environment to free up space.
pip uninstall package_name
pip uninstall numpypip install package_name adds packages to your environment, while pip uninstall removes them to free up disk space.