homework5git/if/if05.py

26 lines
612 B
Python

#!/usr/bin/python3
# Program: if03
# Lists of numbers. These could be integers or floats.
intList = [7, 2, 16, 18, 12, 21]
# Print the list and the length
print(intList," length = ",len(intList))
print(f"Print each value in the list")
counter = 0
for item in intList:
print(f"intList[{counter}] = {item:2d}")
counter += 1
cutoff = 13
print(f"Print each value in the list >= {cutoff}")
counter = 0
for item in intList:
if(item >= cutoff):
print(f"intList[{counter}] = {item:2d}")
else:
print(f"========> intList[{counter}] = {item:2d} is less than {cutoff}")
counter += 1