CodePudding user response:
An inverted pyramid with 1 picture, all layers and is the answerCodePudding user response:
While True:A=input (" please enter the amount:)
Try:
If the int (a) & gt;=0:
Money=int (float (a))
Money_lesss=round ((float (a) - money), 3)
Water_total=(2 * money) - 1
Print (" you can buy {} bottle of water, the remaining ${} money enough to buy water,, "
. The format (water_total money_lesss))
The else:
Print (" the amount of money without negative ")
Except the Exception as re:
Print (" please enter the amount of provisions ")
CodePudding user response:
Can be split:A dollar can buy 1 bottle of
Two dollars can buy three bottles of
3 dollars can buy five bottles of
4 dollars can buy seven bottles of
Five dollars can buy 9 bottles of
Just 2 n + 1 arithmetic progression, money can be understood as a count (of course must be integer), can drink the water of the understanding to the value of the item number, so that you can get the answer
CodePudding user response:
Program is a little small bug, test, fractional function perfect once again good, is the idea