How can I measure elapsed time in Python?

I’m working on a Python program, and I need to measure the time it takes for certain operations to run. How can I measure the elapsed time in Python? Are there any built-in functions or libraries that I can use?

I’ve tried using the time module, but I’m not sure how to use it correctly. Here’s an example of what I’ve tried:

However, I’m not sure if this is the best way to measure elapsed time. Can anyone help me figure out if there’s a better way to do this? Also, are there any other libraries or functions that I can use to measure elapsed time more accurately or in a more granular way? Thank you for any help you can provide.