In [1]:
cat = True
dog = False
print(type(cat))
Use the Boolean operators to determine if the following pairs of values are equivalent:
In [13]:
from cities import cities
In [14]:
print(cities)
first_alb = cities[0] == 'Albuquerque'
second_alb = cities[1] == 'Albuquerque'
first_last = cities[0] == cities[-1]
In [15]:
print(first_alb, second_alb, first_last)
The variable crime_rates is a list of integers containing the crime rates from the dataset. Perform the following comparisons:
In [16]:
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]
In [17]:
print(first_500, first_749, first_last)
The variable crime_rates is a list containing the crime rates from the dataset as integers. Perform the following comparisons:
In [18]:
second = crime_rates[1]
second_500 = second < 500
second_371 = second <= 371
second_last = second <= crime_rates[-1]
In [19]:
print(second_500, second_371, second_last)