1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Anastasy [175]
3 years ago
13

Python provides a special version of a decision structure known as the ________ statement, which makes the logic of the nested d

ecision structure simpler to write.
Computers and Technology
1 answer:
IrinaVladis [17]3 years ago
7 0

Answer:

if-elif-else                                            

Explanation:

In Python if condition is used to decide whether a statement or a block of statements is to be executed or not based on the condition, if the condition evaluates to true then the block of statements is executed and if the condition is false then it is not executed.

Sometimes we need to execute some other statement when the condition is false. For example

if (number1 <= number2)

print (number1,  "is the smallest")

Lets suppose we want to print another statement if this condition evaluates to false. If the condition gets false then the following message should be displayed:

print(number 2, "is the smallest")

For this purpose else statement is used along with if statement to execute the block of code when the if condition evaluates to false.

if (number1 <= number2)

print (number1,  "is the smallest")

else:

print(number 2, "is the smallest")

Now what if there are three numbers or more numbers to be compared in order to identify the smallest number from the given numbers. So in this case we have multiple options to be checked. else statement will not be enough a  for else there can be at most one statement. With if elif else multiple conditions can be checked and if any of the condition evaluates to true then its block of code is executed and if none of the condition is true then the last else statement will be executed.

For example:

if (number1 <= number2) and (number1 <= number3):

print (number1,  "is the smallest")

elif (number2 <= number1) and (number2 <= number3):

print (number1,  "is the smallest")

else:

print (number3,  "is the smallest")

In this example number1 is compared to number2 and number3. If both numbers are less than number1 then the program control goes to elif statement where number2 is compared to number1 and number3. if this condition is false too then the final else part will be printed which is that number3 is the smallest.

Take another example where there are more number of expressions to be checked.

val = 50

if (val == 40):  

   print ("value is 40")  

elif (val== 35):  

   print ("value is 35")  

elif (val == 25):  

   print ("value is 25")  

elif(val==15):

    print ("value is 15")  

else:  

   print ("value is not present")

This will output the else part value is not present, because none of the condition evaluates to true.

You might be interested in
Write c program to check character is alphabate or not?​
Elan Coil [88]

Lookup the isalpha() function in the C standard library, this function will check and return non-zero for alphabetic characters.

8 0
3 years ago
Which subexpression will be solved first in the given statement?
Crazy boy [7]

Answer:

If you dont buy terraria than im going to make mrbeast buy it for you

Explanation:

reeeeeeeeeeeeeeeeeeeee

4 0
3 years ago
I WILL UPVOTE!!!!!!!!!!!!!!!!!!
BabaBlast [244]
All of the answers above are correct
5 0
3 years ago
The what toolbar can be customized to the preferences of the user
schepotkina [342]
Is this a multiple choice question?
7 0
3 years ago
Flexplace and telecommuting are similar in that both allow you to _____. work in a location away from the office work different
viva [34]
Flexplace and telecommuting are similar in that both allow you to work in a different location four days a week. 
3 0
3 years ago
Other questions:
  • How does this splitting wedge make work easier?
    15·1 answer
  • Write the percentage 5 1/4 as a decimal​
    8·1 answer
  • Which principle of animation deals with imparting a unique identity to the animated character?
    5·1 answer
  • A Ground Fault Circuit Interrupter (GFCI) works by comparing the amount of current going to and returning from equipment along t
    10·2 answers
  • Professionalism is defined as what?<br> ASAP PLEASE!
    11·1 answer
  • You recently started working part-time in a retail store, and are learning about the reading devices your store uses. Your store
    6·1 answer
  • 1)When the liquid is spun rapidly, the denser particles are forced to the bottom and the lighter particles stay at the top. This
    10·1 answer
  • Blending two or more colours is called​
    6·1 answer
  • When a Select Case statement executes, the value of the test expression is compared with the values that follow each of the ____
    7·1 answer
  • Handhed computer is otherwise called as<br> 1.laptop<br> 2.Notebook<br> 3.Palmtop
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!