Advertisement
Guest User

Untitled

a guest
May 28th, 2015
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.39 KB | None | 0 0
  1. #
  2. # PSP Assignment 2 Module
  3. # Study Period 2, 2015
  4. #
  5. # File: list_function.py
  6. # Author: your name
  7. # Email Id: your email id
  8. # Description: ...description goes here - written by you.
  9. # This is my own work as defined by the University's
  10. # Academic Misconduct policy.
  11. #
  12.  
  13. #
  14. # Write your function definitions in this file.
  15. # Place your own comments in this file also.
  16. #
  17.  
  18.  
  19. # Function length() - place your own comments here... : )
  20. def length(my_list):
  21.  
  22. # This line will eventually be removed - used for development purposes only.
  23. #print("In function length()")
  24.  
  25. # Place your code here
  26. count = 0
  27. for character in my_list:
  28. count = count + 1
  29.  
  30. return count
  31.  
  32.  
  33.  
  34. # Function to_string() - place your own comments here... : )
  35. def to_string(my_list, sep=', '):
  36.  
  37. # This line will eventually be removed - used for development purposes only.
  38. print("In function to_string()")
  39. string = ""
  40. print("List is: ", end ="")
  41.  
  42. # Place your code here
  43. for element in range(len(my_list)):
  44. string += str((my_list[element]))
  45.  
  46. return string
  47.  
  48.  
  49.  
  50. # Function count() - place your own comments here... : )
  51. def count(my_list, value):
  52.  
  53. # This line will eventually be removed - used for development purposes only.
  54. print("In function count()")
  55.  
  56. # Place your code here
  57.  
  58.  
  59. # Function find() - place your own comments here... : )
  60. def find(my_list, value):
  61.  
  62. # This line will eventually be removed - used for development purposes only.
  63. print("In function find()")
  64.  
  65. # Place your code here
  66.  
  67.  
  68. # Function starts_with() - place your own comments here... : )
  69. def starts_with(list1, list2):
  70.  
  71. # This line will eventually be removed - used for development purposes only.
  72. print("In function starts_with()")
  73.  
  74. # Place your code here
  75.  
  76.  
  77. # Function remove_value() - place your own comments here... : )
  78. def remove_value(my_list, value):
  79.  
  80. # This line will eventually be removed - used for development purposes only.
  81. print("In function remove_value()")
  82.  
  83. # Place your code here
  84.  
  85.  
  86. # Function insert() - place your own comments here... : )
  87. def insert(list1, list2, index):
  88.  
  89. # This line will eventually be removed - used for development purposes only.
  90. print("In function insert()")
  91.  
  92. # Place your code here
  93.  
  94.  
  95. # Function reverse() - place your own comments here... : )
  96. def reverse(my_list, number):
  97.  
  98. # This line will eventually be removed - used for development purposes only.
  99. print("In function reverse()")
  100.  
  101. # Place your code here
  102.  
  103.  
  104. # Function replace() takes a string, an old value, and a new value as
  105. # parameters. The function returns a copy of the string with all occurrences
  106. # of the old value replaced by the new value.
  107. # Please do NOT modify this function. You should call this function from
  108. # within function replace_from_file.
  109. def replace(my_string, old_value, new_value):
  110. new_string = ""
  111.  
  112. for char in my_string:
  113. if char == old_value:
  114. new_string = new_string + new_value
  115. else:
  116. new_string = new_string + char
  117.  
  118. return new_string
  119.  
  120.  
  121. # Function reverse() - place your own comments here... : )
  122. def replace_from_file(filename):
  123.  
  124. # This line will eventually be removed - used for development purposes only.
  125. print("In function replace_from_file()")
  126.  
  127. # Place your code here
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement