If you happen to learn programming from a textbook, you may have seen an example where you are told to exercise writing a quick program that allows you to find the product of elements, for example:
Continue readingPage 11 of 55
One task that you need to do in your day-to-day work is to reverse a list.
One of the most common ways you can do that is by calling the reverse() method:
Continue readingIf you want to print multiple things in the same line, you do not need to clutter everything with the plus operator, or do some type of conversion and then do the concatenation.
For that, we are going to use the help of the “end” parameter inside the print() method indicating the type of separator that you want to use between the items that you want to print.
Continue readingOne of the first commands that you have probably written when you started your journey learning programming was printing a “Hello World” statement:
Did you know that you can print more than just a “Hello World” or other things in a single line?
Continue readingLet’s assume that you want to find the difference between 2 numbers. As you probably remember from school, the difference is not commutative, meaning that:
a — b != b -aContinue reading
Dictionaries represent a commonly used data structure in many scenarios. You may also have cases when you need to merge 2 dictionaries, for example, given that we have 2 equal keys, we want to get the value of the second dictionary.
Continue readingOne of the most common ways to introduce someone to programming is by starting with printing Hello World and then showing them how to do math operations using simple coding instructions.
Continue readingLists are pretty much widely used throughout every project that you can think of. Tuples, on the other hand, are not that common, but both of them have something in common that you can use right away.
You can use the same method for both of them to find indexes of certain elements.
Continue readingYou have been doing math calculations since a very young age, from adding two numbers, to multiplying, dividing, and finding the square root of a number by hand.
In Python, you can also multiply a string with a number.
Yes, you read that right. You do not have to do something big, or fancy: You can just take a string and multiply it with any natural number.
You may be wondering, “What’s the result? I know what is 3 * 3, but I don’t know what’s going to be the result of 3 * ‘abc’?”
Continue readingIn a lot of projects, there are usually a lot of symbols-like constants that are used throughout the application.
They could be currency symbols, weather types, clothes sizes, etc.
Continue reading