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
What is a computer network?
Contact [7]

Answer:

A computer network is a group of two or more computers that are linked together. Networks are usually used to share resources, exchange files or communicate with other users. so A

Explanation:

7 0
2 years ago
To protect the computer network of a large organization, network engineers monitor network traffic. This traffic is compared to
ioda

Answer:

To protect the computer network of a large organization, network engineers monitor network traffic. Malware detection method of data mining best being used to protect the network.

Explanation:

Data mining has excellent potential as a malware detection tool. It allows us to analyze vast sets of information and gives an opportunity to extract new data from it. It also provides the ability to identify both known and zero-day attacks.

5 0
2 years ago
Read 2 more answers
Citations that are ______________________________ can be used to build a bibliography when needed. [Create and Modify Citation S
VMariaS [17]

Answer:

I think the best option would be C. Marked

Explanation:

hope this helps and sorry if it is incorrect.

8 0
3 years ago
What is the key difference between UDP and TCP protocols in TCP/IP reference model?
g100num [7]

Answer:

TCP is a connection-oriented protocol, whereas UDP is a connectionless protocol. The speed for TCP is slower while the speed of UDP is faster.

5 0
1 year ago
Read 2 more answers
Word processing programs have different view options that you can use depending on the tasks you’re performing. Which option hel
gizmo_the_mogwai [7]
Preview, in MS word. It goes for print or publishing, whatever you desire.
7 0
3 years ago
Other questions:
  • How to use javascript libraries in javascript code?
    9·1 answer
  • Jax needs to write a block of code that will organize a list of items alphabetically. Which function should he use? append() pri
    12·1 answer
  • After stating your thesis, follow up by demonstrating the importance of the topic, and explain why the audience or future audien
    14·1 answer
  • PLEASE HELP ME ON THIS..............PLEASEEEEEEEEEEEE PLEASEEEEEE<br><br> ITTS EASYYYYYYYY
    12·1 answer
  • A computer lab has two printers. Printer I handles 40% of all the jobs. Its printing time is Exponential with the mean of 2 minu
    8·1 answer
  • A network that typically reaches a few meters, such as up to 10 meters (33 feet), and consists of personal devices such as mobil
    14·1 answer
  • Roark has just joined a company and in his role as a lead analyst, he will be responsible for determining which systems developm
    11·1 answer
  • a pair of shoes is on sale for 15% off with this discount customers will pay $9 if they buy the shoes ​
    14·1 answer
  • How do i know my child's login info for parent infinite campus
    14·1 answer
  • Drag the tiles to the correct boxes to complete the pairs.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!