<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 1
Step1:  2
Step2:  3
Step3:  4
Step4:  5
Step5:  6
Step6:  7
Step7:  8
<ASSISTANT_TASK:>
Python Code:
cat = True
dog = False
print(type(cat))
Explanation: 1: Booleans
Instructions
Assign the value True to the variable cat and the value False to the variable dog. Then use the print() function and the type() function to display the type for cat.
Answer
End of explanation
from cities import cities
print(cities)
first_alb = cities[0] == 'Albuquerque'
second_alb = cities[1] == 'Albuquerque'
first_last = cities[0] == cities[-1]
print(first_alb, second_alb, first_last)
Explanation: 2: Boolean operators
Instructions
Use the Boolean operators to determine if the following pairs of values are equivalent:
first element of cities and the string "Albuquerque". Assign the resulting Boolean value to first_alb
second element of cities and the string "Albuquerque". Assign the resulting Boolean value to second_alb
first element of cities and the last element in cities. Assign the resulting Boolean value to first_last
End of explanation
crime_rates = [749, 371, 828, 503, 1379, 425, 408, 542, 1405, 835, 1288, 647, 974, 1383, 455, 658, 675, 615, 2122, 423, 362, 587, 543, 563, 168, 992, 1185, 617, 734, 1263, 784, 352, 397, 575, 481, 598, 1750, 399, 1172, 1294, 992, 522, 1216, 815, 639, 1154, 1993, 919, 594, 1160, 636, 752, 130, 517, 423, 443, 738, 503, 413, 704, 363, 401, 597, 1776, 722, 1548, 616, 1171, 724, 990, 169, 1177, 742]
print(crime_rates)
first = crime_rates[0]
first_500 = first > 500
first_749 = first >= 749
first_last = first >= crime_rates[-1]
print(first_500, first_749, first_last)
Explanation: 3: Booleans with greater than
Instructions
The variable crime_rates is a list of integers containing the crime rates from the dataset. Perform the following comparisons:
evaluate if the first element in crime_rates is larger than the integer 500, assign the Boolean result to first_500
evaluate if the first element in crime_rates is larger than or equal to 749, assign the Boolean result to first_749
evaluate if the first element in crime_rates is greater than or equal to the last element in crime_rates, assign the Boolean result to first_last
Answer
End of explanation
second = crime_rates[1]
second_500 = second < 500
second_371 = second <= 371
second_last = second <= crime_rates[-1]
print(second_500, second_371, second_last)
Explanation: 4: Booleans with less than
Instructions
The variable crime_rates is a list containing the crime rates from the dataset as integers. Perform the following comparisons:
* determine if the second element in crime_rates is smaller than the integer 500, assign the Boolean result to second_500
* determine if the second element in crime_rates is smaller than or equal to 371, assign the Boolean result to second_371
* determine if the second element in crime_rates is smaller than or equal to the last element in crime_rates, assign the Boolean result to second_last
Answer
End of explanation
result = 0
if cities[2] == u"Anchorage":
    result = 1
assert result == 1
Explanation: 5: If statements
Instructions
Determine if the third element in cities is equivalent to the string "Anchorage". If it is equivalent, change the variable result to 1.
Answer
End of explanation
reqults = 0
if crime_rates[0] > 500:
    if crime_rates[0] > 300:
        results = 3
Explanation: 6: Nesting if statements
Instructions
Nest if statements in the following order:
first one checks if the first element in crime_rates is larger than 500
second one checks if the second element in crime_rates is larger than 300
if both statements evaluate to True, assign the value 3 to the variable results
Answer
End of explanation
five_hundred_list = []
for cr in crime_rates:
    if cr > 500:
        five_hundred_list.append(cr)
assert all([_>500 for _ in five_hundred_list])
Explanation: 7: If statements and for loops
Instructions
Create a new list, five_hundred_list, that contains only the elements from crime_rates that are greater than 500. To accomplish this, you'll need a for loop and an if statement:
the for loop specifies which list we want to iterate over and the name of the iterator variable (we use cr in our answer)
the if statement determines if the current element (cr) is larger than 500
if the current element (cr) is larger than 500, use the append() method to add it to five_hundred_list
Answer
End of explanation
print(crime_rates)
highest = crime_rates[0]
for cr in crime_rates:
    if cr > highest:
        highest = cr
Explanation: 8: Find the highest crime rate
Instructions
Now [...] we can find the highest crime rate. crime_rates is a list of integers where each integer is a crime rate.
One strategy is to:
assign the value at index 0 from crime_rates to a new integer variable called highest
use a for loop to compare each value in crime_rates to highest and assign that value to highest if it's larger
Find the largest integer in crime_rates using the strategy we just discussed and assign that value to the variable highest.
Answer
End of explanation
<END_TASK>