4 5 Determines the distance traveled by a bouncing ball. 6. 7 Inputs: Initial height, bounciness index, and number of bounces II I| || 9 10 from breezypythongui import EasyFrame 11 12 def computeDistance(height, index, bounces): 13 I "Computes the total distance traveled by the ball, given an initial height, bounciness index, and number of bounces." || | 14 15 16 pass 17 18 class BouncyGUI(EasyFrame): 19 def --init_-(self): "I"Set up the window and widgets.""" EasyFrame._init__(self, ""Define the following fields""" # self.heightField (number entry) # self.indexField (number entry) # self.bouncesField (number entry) # self.distanceField (result result) 20 21 22 title = "Bouncy") 23 24 25 26 27 28 29 def computeDistance(self): 30 II I| || 31 Event handler for the Compute button and set the 32 distanceField. 33 II II|| 34 pass 35 36 def main(): 37 I" I| "Instantiate and pop up the window.""" 38 BouncyGUI ( ).mainloop() 39 40 if --name__ -_main__": 41 main() 42 43
Control structures
Control structures are block of statements that analyze the value of variables and determine the flow of execution based on those values. When a program is running, the CPU executes the code line by line. After sometime, the program reaches the point where it has to make a decision on whether it has to go to another part of the code or repeat execution of certain part of the code. These results affect the flow of the program's code and these are called control structures.
Switch Statement
The switch statement is a key feature that is used by the programmers a lot in the world of programming and coding, as well as in information technology in general. The switch statement is a selection control mechanism that allows the variable value to change the order of the individual statements in the software execution via search.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images