Joke Collection Website - Joke collection - How to write this python program, please write down the programming and ideas, thank you.

How to write this python program, please write down the programming and ideas, thank you.

This is actually solving a linear equation.

Suppose you can drink x bottles of beer, x empty bottles can be exchanged for x/2 bottles of beer without paying, and x bottle caps can be exchanged for x/4 bottles of beer without paying.

So, the equation is:

(x-x/2-x/4)*2= 10

The specific code is as follows:

x=4

Although correct:

if (x-x/2-x/4)*2== 10:

Print (x)

break

x+=4

The following is a screenshot of the operation: