Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

PYTHON 3 (NOT JAVA) 1. Clunker Motors Inc. is recalling all vehicles from model

ID: 3843808 • Letter: P

Question

PYTHON 3 (NOT JAVA)

1.Clunker Motors Inc. is recalling all vehicles from model years 2001-2006. Given a variable modelYear write a statement that assigns Trueto recalled if the value of modelYear falls within the recall range and assigns False otherwise.Do not use an if statement in this exercise!

2.Write a statement that toggles on_off_switch. That is, if on_off_switch is False, it is made equal to True; if on_off_switch is True, it is made equal to False.

3.Assume that x is a string variable has been given a value. Write an expression whose value is true if and only if x is a lower-case letter.

4.Assume that x is a string variable has been given a value. Write an expression whose value is true if and only if x is NOT a letter.

Explanation / Answer

#!/usr/bin/python

data = int(input("Enter a modelyear: "))
List = [2001,2002,2003,2004,2005,2006]
print data in List
> if on_off_switch else True
print on_off_switch
> if on_off_switch else True
print on_off_switch
x = "a"
reponse = True if (any(i.islower() for i in x)) else False
print response
x = "1"
reponse1 = False if (any(i.islower() for i in x) || any(i.isupper() for i in x)) else True
print response1
x = "A"
reponse1 = False if (any(i.islower() for i in x) || any(i.isupper() for i in x)) else True
print response1