Advertisement
ganiyuisholaafeez

List Declaration and Assignment

Feb 22nd, 2020
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.81 KB | None | 0 0
  1. """ This section tests your level of understanding with List """
  2. # The first three following statements address the declaration
  3. # of list objects and assignment to suitable variables
  4. active = [True]
  5. favorite_numbers = [23, 3, 33, 59, 8]
  6. colors = ["red", "green", "blue"]
  7.  
  8. #Invocation of the Variables
  9. print(active)
  10. print(favorite_numbers)
  11. print(colors, "\n")
  12.  
  13. # This function called is_long() determines the length of a list argument
  14. # Thereby returning Boolean True for a length greater than 5 and False otherwise
  15. def is_long(size):
  16.     if len(size) > 5: # Stating the condition
  17.         return True
  18.     else:
  19.         return False
  20.  
  21. print(is_long([3, 5, 6, 9])) # The length is 4 = False
  22. print(is_long([3, 5, 6, 9, 56])) # The length is 5 = False
  23. print(is_long([3, 5, 6, 9, 4, 2])) # The length is 6 = True
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement