80.0k views
1 vote
Clunker Motors Inc. is recalling all vehicles from model years 2001-2006. A bool variable named norecall has been declared . Given an int variable modelYear write a statement that assigns true to norecall if the value of modelYear does NOT fall within the recall range and assigns false otherwise. Do not use an if statement in this exercise!

User Kishath
by
3.7k points

1 Answer

5 votes

Answer:

The statement (in Python) is as follows:

recalled = modelYear >=2001 and modelYear <=2006

Step-by-step explanation:

Required

A statement without an if statement to assign true or false to recalled

Using an if statement, the comparison is

if modelYear >=2001 and modelYear <=2006:

recalled = True

else:

recalled = False

To rewrite the statement without using the "if" keyword, we simply equate variable recalled to the stated condition i.e.

recalled = modelYear >=2001 and modelYear <=2006

Note that, we assume that there is an input fo variable modelYear

User FrankyBoy
by
4.1k points