![]() if-elseįor a computer to make decisions based on a condition, you must use an IF statement, it has the following structure: Life is full of decisions that you will make depending on certain conditions, computers are no different. ![]() ![]() IF the day is a Saturday AND the alarm clock goes off THEN you might turn it off and stay in bed OTHERWISE you might get up. IF you wake up in the morning and it is raining THEN you will take a coat to school OTHERWISE you wont. Sometimes you will change what do you depending on the conditions. #three variables that store the two inputs and also the value of pie radius = float ( input ( "Enter the cylinder radius: " )) height = float ( input ( "Enter the cylinder height: " )) pie = 3.14159 #calculations to work out the volume and surface area volume = pie * ( radius * radius ) * height surface = ( 2 * ( pie * ( radius * radius ))) + ( 2 * ( pie * radius * height )) #outputs the volume and surface area of the cylinder print ( "The volume of your cylinder is", round ( volume, 2 ), "to 2 decimal places" ) print ( "The surface area of your cylinder is", round ( surface, 2 ), "to 2 decimal places" )
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |