Software engineering and personal development

Month: April 2022

How to Quickly Generate Fake Data in Python using Faker

person using phone and laptop computer
Photo by Austin Distel on Unsplash

Testing your code is a great way to check whether you have implemented everything correctly. No matter how much you try, no matter how hard you analyze all the cases, sometimes, just the smallest mistake can lead to a big problem which could have maybe been avoided writing tests.

When you write tests, you are obviously not going to use data from production. We need to use some dummy data that does not belong to anyone who is actually using the project. This is called faking the data.

Continue reading

How to Quickly Check Whether a Variable is a Number in Python

photo of man walking near LED signage
Photo by Ryoji Iwata on Unsplash

Since you don’t have a predefined type for a variable in Python, you may notice a lot of bugs that can arise. As such, it is very important that you pay a lot of attention in cases when you have to make sure that you are using the correct type of variable.

This can also be the case when you expect a variable to be a number, but you get a string or any other type instead.

Continue reading

How to Quickly Convert 2 Lists Into a Dictionary in Python

Get a driver's-eye view of other cars driving along the 110 Freeway in Los Angeles as they pass under the soaring interchange with the 105 Freeway. This is quintessential L.A. architecture and a typical view for thousands of people every commute.  Another sunny day in paradise.
Photo by Chris Linnett on Unsplash

Two of the most common data structures in Python are lists and dictionaries. If you take a look back at your code, you may notice that you have a lot of lists and dictionaries used all over the place.

They may look quite similar, but they have a key difference. You can think of a list as a collection of items, and a dictionary as a collection of key-value pairs.

There can be cases when you may need to do a conversion of 2 lists into a single dictionary. This is something that you can easily do in Python with the help of zip() function.

Continue reading

© 2024 Fatos Morina

Theme by Anders NorenUp ↑