123k views
1 vote
Clunker Motors Inc. is recalling all vehicles in its Extravagant line from model years 1999-2002 as well all vehicles in its Guzzler line from model years 2004-2007. A boolean variable named recalled has been declared. Given a variable modelYear and a String modelName write a statement that assigns true to recalled if the values of modelYear and modelName match the recall details and assigns false otherwise.

User Falsetto
by
4.6k points

1 Answer

1 vote

Answer:

Following are the program in the Python Programming Language.

#set user defined integer variable

modelYear=int(input("Enter year from 1999 to 2002 or from 2004 to 2007: "))

#set user defined string variable

modelName=input("Enter the vehicle name 'Extravagant' or 'Guzzler': ")

#set if statement

if((modelYear>=1999 and modelYear<=2002 and modelName=="Extravagant") or (modelYear>=2004 and modelYear<=2007 and modelName=="Guzzler")):

recalled=True #if the statement is true

else:

recalled=False #if the statement is not true

print(recalled) #print boolean type

Output:

Enter year from 1999 to 2002 or from 2004 to 2007: 2001

Enter the vehicle name 'Extravagant' or 'Guzzler': Extravagant

True

Step-by-step explanation:

Here, we set a user defined integer data type variable "modelYear" and assign value from the user then, we set a user defined string data type variable "modelName" and assign value from the user.

Then, we set the if statement and pass the condition when modelYear is greater than equal to 1999 and less than equal to 2002 and modelName is equal to "Extravagant" or modelYear is greater than equal to 2004 and less than equal to 2007 and modelName is equal to "Guzzler" than "recalled" is equal to True otherwise "recalled" is equal to False.

Finally, we print the value of the variable "recalled".

User Shkarik
by
5.1k points