Posts for: #Python

Interest and Logic

One of the logic problems in programming that most break the head of those who are starting are the problems with percentage calculation or interest.

It starts like this: Calculate 10% increase on a salary of $2,500.00

Depending on the student’s math background, percentage is learned in 4th/5th grade… some concepts need to be remembered. As the name says, 10% means that for every 100 of the value, you should subtract 10. The calculation is quite simple and can be done with a multiplication. For example: 10/100 * 2500, which results in 250. So far so good, but some students ask why sometimes we do 0.1 * 2500. Well, it’s just the way of representation that changes, because 10/100 is equivalent to 0.1, alias 100/1000 also and so on. But this is the easy part and after getting the notation right, things start working again.

Read more

Interest and Logic

One of the logic problems in programming that most break the head of those who are starting are the problems with percentage calculation or interest.

It starts like this: Calculate 10% increase on a salary of $2,500.00

Depending on the student’s math background, percentage is learned in 4th/5th grade… some concepts need to be remembered. As the name says, 10% means that for every 100 of the value, you should subtract 10. The calculation is quite simple and can be done with a multiplication. For example: 10/100 * 2500, which results in 250. So far so good, but some students ask why sometimes we do 0.1 * 2500. Well, it’s just the way of representation that changes, because 10/100 is equivalent to 0.1, alias 100/1000 also and so on. But this is the easy part and after getting the notation right, things start working again.

Read more

Graphical Effects with Python, Tkinter, Cython, and Numba

Yesterday, Saturday, I felt like creating a flame effect (fire) in Python. This effect was quite popular in the early 90s. I remembered that the algorithm was quite simple, but there were some tricks to do with the color palette.

I found this article with the implementation in C: https://lodev.org/cgtutor/fire.html

From the same article, we can get an idea of how the effect looks:

Flame Effect

After reading the article and watching some videos on YouTube, I faced two problems:

Read more

Graphical Effects with Python, Tkinter, Cython, and Numba

Yesterday, Saturday, I felt like creating a flame effect (fire) in Python. This effect was quite popular in the early 90s. I remembered that the algorithm was quite simple, but there were some tricks to do with the color palette.

I found this article with the implementation in C: https://lodev.org/cgtutor/fire.html

From the same article, we can get an idea of how the effect looks:

Flame Effect

After reading the article and watching some videos on YouTube, I faced two problems:

Read more