![colors keep changing construct 3 colors keep changing construct 3](https://www.thehappyscraps.com/wp-content/uploads/2020/07/rise-and-shine-cup.jpg)
So the conversion from string was via float, not int.īelow is an equivalent alternative version of the body ofĬalcWeeklyWages, used in wages1.py. Here the input was intended to be numeric, but it could be decimal ''' if totalHours <= 40 : totalWages = hourlyWage * totalHours else : overtime = totalHours - 40 totalWages = hourlyWage * 40 + ( 1.5 * hourlyWage ) * overtime return totalWages def main (): hours = float ( input ( 'Enter hours worked: ' )) wage = float ( input ( 'Enter dollars paid per hour: ' )) total = calcWeeklyWages ( hours, wage ) print ( 'Wages for. It is always executed in the normal forward flow of statements,Īfter the if- else statement (whichever block is selected).ĭef calcWeeklyWages ( totalHours, hourlyWage ): '''Return the total weekly wages for a worker working totalHours, with a given regular hourlyWage. Since its amount of indentation matches the if heading, Since it is dedented, it is not a part of the if-else statement: Removing indentation, about getting exercise. Statement exactly one of two possible indented blocks is executed. In the if- else form this is followed by anĮlse: line, followed by another indented block that is onlyĮxecuted when the original condition is false. If heading and is executed when the condition in the if
![colors keep changing construct 3 colors keep changing construct 3](https://ae01.alicdn.com/kf/HTB1zq3PXPzuK1Rjy0Fpq6yEpFXaD/1Pc-Beauty-Makeup-Gradient-Change-Three-Color-Makeup-Lipstick-Long-lasting-Waterproof-Lipstick-Lip-Balm-Lips.jpg)
One, like in the simple if statement, comes right after the Again it isĬlose to English, though you might say “otherwise” instead of The middle four lines are an if-else statement. Temperature = float ( input ( 'What is the temperature? ' )) if temperature > 70 : print ( 'Wear shorts.' ) else : print ( 'Wear long pants.' ) print ( 'Get some exercise outside.' )