by Suf | Feb 27, 2022 | Programming, Python, Tips
We can measure temperature using two units: Celsius and Fahrenheit. We can convert temperature from degrees Celsius to degrees Fahrenheit using a formula. 12 degrees Celsius is equal to 53.6 degrees Fahrenheit. This tutorial will go through how to convert between the...
by Suf | Feb 26, 2022 | Programming, Python, Tips
In Python, we can only convert specific string values to float. If we try to convert an invalid string to a float, we will raise the ValueError: could not convert string to float. To solve this error, ensure you strip the string of invalid characters like commas,...
by Suf | Feb 26, 2022 | Programming, Python, Tips
If you try to access a closed file, you will raise the ValueError: I/O operation on closed file. I/O means Input/Output and refers to the read and write operations in Python. To solve this error, ensure you put all writing operations before closing the file. This...
by Suf | Feb 26, 2022 | DSA, Programming, Python, Tips
Bubble sort is a popular sorting algorithm that compares the adjacent elements in a list and swaps them if they are not in the specified order. This tutorial will go through how to implement the bubble sort algorithm in Python with the help of code examples. Got some...
by Suf | Feb 25, 2022 | Programming, Python, Tips
The error TypeError: unhashable type: ‘set’ occurs when trying to get a hash of a set object. For example, using a set as a key in a dictionary. To solve this error, we can cast the set to a frozenset or a tuple, which are both hashable container objects. This...
by Suf | Feb 24, 2022 | Programming, Python, Tips
The error TypeError: unhashable type: ‘numpy.ndarray’ occurs when trying to get a hash of a NumPy ndarray. For example, using an ndarray as a key in a Python dictionary because you can only use hashable data types as a key. We can use the update() method to...