462500.3140334.qx3zqy7 Jump to level 1 Write an if-else statement for the following: If num_difference is not equal to -15, execute total_difference = -10. Else, execute total_difference = num_difference. 1 num_difference = int(input()) # Program will be tested with values: -13 -14 -15 -16. 2 | 3 Your code goes here 5 print(total_difference) IN3456
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.
Program Approach:
- Step 1: Create a user input integer variable num_difference for taking integer input from the user.
- Step 2: Check whether num_difference is not equal to -15. Set total_difference equal to -10.
- Step 3: Otherwise, set total_difference equal to num_difference.
- Step 4: Display total_difference.
Step by step
Solved in 3 steps with 5 images