Questions
Python questions
Choose a question page, learn the concept, then test your understanding with a quiz.
How to Pad a String with Leading Zeros in JavaScript
Learn how to pad numeric strings with leading zeros in JavaScript using padStart and simple alternatives.
How to Parse Date Strings into datetime Objects in Python
Learn how to convert strings like "Jun 1 2005 1:33PM" into Python datetime objects using datetime.strptime with clear examples.
How to Parse a String to int or float in Python
Learn how to convert strings to int and float in Python, handle invalid input safely, and avoid common parsing mistakes.
How to Pretty-Print JSON in Python
Learn how to pretty-print JSON in Python using the json module, indentation, sorting, and file output with clear examples.
How to Print Colored Text to the Terminal in Python
Learn how to print colored text in the Python terminal using ANSI escape codes and practical examples for beginners.
How to Print Without a Newline or Space in Python
Learn how to print without spaces or newlines in Python using print(), end, sep, and sys.stdout.write with clear examples.
How to Print to stderr in Python: sys.stderr.write vs print vs os.write
Learn how to write to stderr in Python, the differences between print, sys.stderr.write, and os.write, and which method to prefer.
How to Profile a Python Script: Timing and Profiling in Python
Learn how to profile a Python script using cProfile, time, and timeit. Understand when to measure total runtime vs bottlenecks in Python code.
How to Raise Exceptions in Python
Learn how to raise exceptions in Python, catch them with except, and use built-in or custom errors correctly with clear examples.
How to Read a File Line by Line into a List in Python
Learn how to read a file line by line into a Python list, with examples, common mistakes, and practical patterns for real projects.
How to Read from stdin in JavaScript
Learn how to read from standard input (stdin) in JavaScript, with Node.js examples, patterns, and beginner-friendly explanations.
How to Remove a Key from a Python Dictionary Safely
Learn how to remove a key from a Python dictionary safely using del, pop, and default values without raising KeyError.
How to Remove an Element from a List by Index in Python
Learn how to remove a list element by index in Python using pop and del, with examples, mistakes to avoid, and practical use cases.
How to Rename DataFrame Columns in Pandas by Removing Characters
Learn how to rename Pandas DataFrame columns by removing characters like $ using rename, str methods, and practical examples.
How to Save a Matplotlib Plot to a File in Python
Learn how to save a Matplotlib plot as PNG or other image files in Python using savefig, with examples and common mistakes.
How to Sort a Dictionary by Value in Python
Learn how to sort a Python dictionary by value in ascending or descending order with clear examples and beginner-friendly explanations.
How to Sort a List of Dictionaries by Key in Python
Learn how to sort a list of dictionaries by a key in Python using sorted() and list.sort() with clear examples and common mistakes.
How to Split Long Strings Across Multiple Lines in Python
Learn the Pythonic ways to split long strings across lines using implicit concatenation, triple quotes, and formatting safely.
How to Split a List Into Equal-Sized Chunks in Python
Learn how to split a Python list into equal-sized chunks with clear examples, step-by-step logic, common mistakes, and a mini project.
How to Upgrade All Python Packages with pip
Learn how to upgrade all installed Python packages with pip, why pip has no single built-in command, and safe ways to do it step by step.