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]
4 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]4 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
What is the name of the most common connector type used for providing power to various hardware components inside computer case?
user100 [1]
The answer is the molex.
4 0
3 years ago
What are the similarities and differences in an electronic crime scene as compared to a traditional crime scene?
geniusboy [140]
Traditional crime scenes have physical evidence while electronic crime scenes have digital evidence such as IP address, geolocation, and user data.
8 0
3 years ago
Help please<br> helpp im begging
NemiM [27]
I think That it is A
6 0
3 years ago
2. Write a program to calculate CGPA of a student. The program should be able to get input from the user of the grade for each c
Irina18 [472]
The easy way to do it is to let an array accept all the inputs and add all the inputs together and divide the sum by how many the input was. 

Example : five + five + five + five + three + two = 25
Now divide twenty five : twenty five / six = 4.1

Letter A is the closest answer.
7 0
3 years ago
What is a filter in excel (please keep your answer brief)
JulijaS [17]

Answer:

The Excel FILTER function "filters" a range of data based on supplied criteria. The result is an array of matching values the original range. When this array is the final result (i.e. the results are not handed off to another function) matching results will "spill" on to the worksheet.

Explanation:

3 0
3 years ago
Other questions:
  • What is a good way to minimize technical problems with your computer
    10·1 answer
  • Give two separate print statements: one will print your name, the other will print your major. Ensure that both will print on th
    15·1 answer
  • What name is used to denote a common field that exists between two tables, but is also the primary key for one of the tables??"
    8·1 answer
  • The merge sort algorithm sorts using what technique?
    8·1 answer
  • Please help me
    10·1 answer
  • Consider the following code snippet: int count = 0; int[][] numarray = new int[2][3]; for (int i = 0; i &lt; 3; i++) { for (int
    15·1 answer
  • Each row in a database is a set of unique information called a(n)
    8·2 answers
  • I need someone's opinion<br> Which format is better? The first or second one? I can't decide 0.0
    15·2 answers
  • Write a program to enter RADIUS of a CIRCLE and PRINT AREA of TRIANGLE using Q Basic. (class 8)​
    9·1 answer
  • Write a program that will predict the size of a population of organisms. The program should ask the user for the starting number
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!