98.3k views
4 votes
Assume that a boolean variable isQuadrilateral has been declared, and that another variable, numberOfSides has been declared and initialized. Write a statement that assigns the value true if numberOfSides is exactly 4 and false otherwise.

User MidasLefko
by
8.7k points

1 Answer

7 votes

Answer:

# The below code is in python programming language.

if(numberOfSides==4): #check the value number of slide is equal to 4 or not.

isQuadrilateral=True # assignment statement for if condition

else:

isQuadrilateral=False # assignment statement for else condition

Step-by-step explanation:

The above code is in python language in which--

  • The first lines are the "if" condition which checks the value of "numberofslides" variable.
  • The second lines assign true in "isQuadrilateral" variable if "if" condition is true.
  • The third line is for "else" statement that executes when the "if" condition is false.
  • The fourth line is for "else" statement which assigns the value false to the numberofslides variables.
User John Keyes
by
7.6k points
Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.