<｜begin▁of▁sentence｜>### Instruction:
Imagine you're embarking on a captivating journey through a network of small towns—each distinct town representing a node, connected by scenic roads with varying levels of charm, symbolized by weights on these edges. As a seasoned tour guide, you've observed that towns seem to form clusters or communities, like a map with different regions, each offering a unique flavor of experiences to the travelers.

Now, let's say you're crafting an exclusive tour package designed around these clusters. To ensure your guests are getting the most cohesive and satisfying experience, you're considering the strength of interactions within these town clusters compared to those between them. This is where the 'graspologic.partition.modularity' API steps in—it's like your compass to assess the harmony within your tour regions.

You want to use this tool to measure the modularity of this picturesque landscape, effectively the network. This gauge will tell you if the towns within each proposed cluster have stronger ties to each other than to towns in other clusters, much like ensuring tourists spend more time at closely-knit attractions that share a common theme or history.

This meticulous evaluation of your regional tour plans using modularity will certify that your guests are not just visiting a collection of towns but experiencing the essence of each unique community. Can you picture how valuable this tool would be in refining your grand tour and delivering an unforgettable journey through these interconnected towns?
### Response:
import networkx as nx
import numpy as np
from graspologic.partition import modularity

# Construct the social network graph
G = nx.Graph()

# Add nodes and weighted edges to the graph
nodes = range(10)
edges = [(i, j, {'weight': np.random.rand()}) for i in nodes for j in nodes if i < j]
G.add_nodes_from(nodes)
G.add_edges_from(edges)

# Define a community partitioning
partitions = {0: 0, 1: 0, 2: 0, 3: 1, 4: 1, 5: 1, 6: 2, 7: 2, 8: 2, 9: 2}

# Calculate the modularity of the given community partitioning
modularity_score = modularity(graph=G, partitions=partitions, weight_attribute='weight', resolution=1.0)

# Print the modularity score
print(modularity_score)
<|EOT|>
