In: Computer Science
CIS- Python
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. Given variables modelYear and modelName write a statement that assigns True to recalled if the values of modelYear and modelName match the recall details and assigns False otherwise.
Python code:
#assigning sample value to modelYear
modelYear=2005
#assigning sample value to modelName
modelName="Guzzler"
#assigning recalled as False
recalled=False
#checking if modelName is Extravagant and modelYear is from
1999-2002
if(modelName=="Extravagant" and modelYear>=1999 and
modelYear<=2002):
#setting recalled to True
recalled=True
#checking if modelName is Guzzler and modelYear is from
2004-2007
elif(modelName=="Guzzler" and modelYear>=2004 and
modelYear<=2007):
#setting recalled to True
recalled=True
#printing the value of recalled
print(recalled)
Screenshot:
Output: