TechVani
1 subscriber
27 links
BTech CSE notes, practical lab files, online tools and AI guides for students. Study in simple English: https://techvaniai.blogspot.com/
Download Telegram
Python exception trap: an error raised in else is not caught by the preceding except. Keep the operation you intend to protect in try, and success-only work in else. Eight tested examples cover handlers, cleanup, return and re-raise, with exact outputs and exam answers: https://techvaniai.blogspot.com/2026/10/python-try-except-else-finally-8-tested.html
Python generator trap: sum consumes a generator, so a second sum on the same exhausted object returns 0. Create a fresh generator for another pass. Eight tested examples explain iterators, yield, lazy pipelines and bounded infinite streams, with exact outputs and practice answers: https://techvaniai.blogspot.com/2026/10/python-iterators-generators-yield-lazy-8-tested.html
Python groupby trap: A A B A makes three adjacent groups, not two global groups. Sort on the same key only when changing the original order fits your task. Eight tested examples explain groupby, accumulate, pairwise, islice and tee, with exact outputs and practice answers: https://techvaniai.blogspot.com/2026/10/python-itertools-groupby-accumulate-8-tested.html
Python sorting trap: values.sort() changes the list but returns None. Use sorted(values) when you need a new list. Eight tested examples explain keys, stable ties, mixed sort directions, missing values and dictionary sorting, with exact outputs and practice answers: https://techvaniai.blogspot.com/2026/10/python-sorted-list-sort-keys-stability-8-tested.html
Python dict/set trap: membership in a dict checks keys, not values. A set removes duplicates but does not guarantee insertion order; dict.fromkeys keeps first appearance. Eight tested examples cover lookup, word counts, set operations, hashable keys and ordering, with exact outputs and practice answers: https://techvaniai.blogspot.com/2026/10/python-dict-vs-set-lookup-deduplication-8-tested.html