Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Booleans

Cat = True

Dog = False

Print(type(cat))

Out- type – bool

First_el = (“Mumbai” == cities[0])

Print(first_el)

Out – True/False

If statement for loops


found = False
for city in cities:
if city == 'Washington':
found = True

Ex. Create a new list, five_hundred_list, that contains only the elements
from crime_rates that are greater than 500

five_hundred_list = [ ]

for row in crime_rates:

if row > 500:

five_hundred_list.append(row)

print(five_hundred_list)

 Ex. Find the largest integer in crime_rates using the strategy we just outlined, and assign that

value to the variable highest .

print(crime_rates)
highest = crime_rates[0]

for row in crime_rates:

if row > highest:

highest = row

print(highest)

You might also like