CHALLENGE ACTIVITY 462500.3140334.qx3zqy7 4.4.2: Basic if-else expression. Jump to level 1 Write an expression that will cause the following code to print "less than -15" if the value of user_num is less than -15. 1 user_num= int(input()) # Program will be tested with values: -14, -15, -16, -17. 2 3 if 4 5 6 7 Your code goes here "*': print('less than -15') print('-15 or more') else:
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.
Algorithm:
- START
- Prompt the user to enter an integer.
- Store the user's input in the variable user_num.
- Compare user_num to -15.
- If user_num is less than -15, print 'less than -15'.
- Else, print '-15 or more'.
- END
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 5 images