Question

Use simple python Devise an experiment that compares the performance of the del operator on lists...

Use simple python

Devise an experiment that compares the performance of the del operator on lists and dictionaries.

a graph displaying the timings of those operators

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#source code:

import timeit
import matplotlib.pyplot as plt
list=["vishnu","vardhan","namana","siva","nagsai","sai"]
dict={"name":"vishnu","class":"sf","age":17,"nicename":"toms"}
#list element delete opeation

start=timeit.timeit()
del list[3]
end=timeit.timeit()
list_time=end-start
print("list delation time:",list_time)

#dictionary element delete opeation

start=timeit.timeit()
del dict["class"]
end=timeit.timeit()
dict_time=end-start
print("list delation time:",dict_time)

plt.plot(["list_time","dict_time"],[list_time,dict_time],"ro")
plt.show()


#output:

#if you have any doubts comment below...

Add a comment
Know the answer?
Add Answer to:
Use simple python Devise an experiment that compares the performance of the del operator on lists...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT