Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #
- # PSP Assignment 2 Module
- # Study Period 2, 2015
- #
- # File: list_function.py
- # Author: your name
- # Email Id: your email id
- # Description: ...description goes here - written by you.
- # This is my own work as defined by the University's
- # Academic Misconduct policy.
- #
- #
- # Write your function definitions in this file.
- # Place your own comments in this file also.
- #
- # Function length() - place your own comments here... : )
- def length(my_list):
- # This line will eventually be removed - used for development purposes only.
- #print("In function length()")
- # Place your code here
- count = 0
- for character in my_list:
- count = count + 1
- return count
- # Function to_string() - place your own comments here... : )
- def to_string(my_list, sep=', '):
- # This line will eventually be removed - used for development purposes only.
- print("In function to_string()")
- string = ""
- print("List is: ", end ="")
- # Place your code here
- for element in range(len(my_list)):
- string += str((my_list[element]))
- return string
- # Function count() - place your own comments here... : )
- def count(my_list, value):
- # This line will eventually be removed - used for development purposes only.
- print("In function count()")
- # Place your code here
- # Function find() - place your own comments here... : )
- def find(my_list, value):
- # This line will eventually be removed - used for development purposes only.
- print("In function find()")
- # Place your code here
- # Function starts_with() - place your own comments here... : )
- def starts_with(list1, list2):
- # This line will eventually be removed - used for development purposes only.
- print("In function starts_with()")
- # Place your code here
- # Function remove_value() - place your own comments here... : )
- def remove_value(my_list, value):
- # This line will eventually be removed - used for development purposes only.
- print("In function remove_value()")
- # Place your code here
- # Function insert() - place your own comments here... : )
- def insert(list1, list2, index):
- # This line will eventually be removed - used for development purposes only.
- print("In function insert()")
- # Place your code here
- # Function reverse() - place your own comments here... : )
- def reverse(my_list, number):
- # This line will eventually be removed - used for development purposes only.
- print("In function reverse()")
- # Place your code here
- # Function replace() takes a string, an old value, and a new value as
- # parameters. The function returns a copy of the string with all occurrences
- # of the old value replaced by the new value.
- # Please do NOT modify this function. You should call this function from
- # within function replace_from_file.
- def replace(my_string, old_value, new_value):
- new_string = ""
- for char in my_string:
- if char == old_value:
- new_string = new_string + new_value
- else:
- new_string = new_string + char
- return new_string
- # Function reverse() - place your own comments here... : )
- def replace_from_file(filename):
- # This line will eventually be removed - used for development purposes only.
- print("In function replace_from_file()")
- # Place your code here
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement