Added lecture 2026113
This commit is contained in:
parent
be356ccb59
commit
5b630435ae
27 changed files with 738 additions and 0 deletions
41
lecture20261103/lists02/lists01-define-and-print.py
Normal file
41
lecture20261103/lists02/lists01-define-and-print.py
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
# Defining and printing list lengths.
|
||||
|
||||
# Lists of text values
|
||||
dogNames = [ "harry", "Shenanigans","katrina","Tanner","Yukon Jack", "Colorado","Mandy"]
|
||||
firstNames = ["edward","david", "Bob","mary","alice"]
|
||||
txtList = ["7", "2", "12", "18", "16", "21"]
|
||||
|
||||
# Lists of nubers. These could be integers or floats.
|
||||
intList = [7, 2, 12, 18, 16, 21]
|
||||
primeList = [1, 2, 3, 7, 11, 13, 17, 19]
|
||||
|
||||
# Print the entire list
|
||||
print("Print the entire list.")
|
||||
print (dogNames)
|
||||
print(firstNames)
|
||||
print(txtList)
|
||||
print(intList)
|
||||
print(primeList)
|
||||
print("\n")
|
||||
|
||||
|
||||
# Print the length of the list
|
||||
print("Print the length of the lists.")
|
||||
print( len(dogNames) )
|
||||
print(len(firstNames) )
|
||||
print(len(txtList) )
|
||||
print(len(intList) )
|
||||
print(len(primeList) )
|
||||
print("\n")
|
||||
|
||||
|
||||
# Print the list and the length
|
||||
print("Print the length of the lists.")
|
||||
print (dogNames," length = ",len(dogNames))
|
||||
print(firstNames," length = ",len(firstNames))
|
||||
print(txtList," length = ",len(txtList))
|
||||
print(intList," length = ",len(intList))
|
||||
print(primeList," length = ",len(primeList))
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue