Added code for lecture 2026-11-10
This commit is contained in:
parent
5b630435ae
commit
07b9e54bf0
52 changed files with 1248 additions and 1 deletions
25
lecture20261110/if/if05.py
Normal file
25
lecture20261110/if/if05.py
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
#!/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
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue