< Back

Post Lab 16

Post labs are to be done individually. Sharing files between students is not allowed. Doing so is an Academic Integrity violation, and will be treated as such.


In this post lab, you will demonstrate your knowledge of strings by writing a simple function to create a copy of a segment of a given string.

Details

Create a function called string_slice(input_string, start_index, end_index) in a filed called slicing.py. This function takes a string and two positive integers as parameters. The function should return a copy of the characters from input_string between the specified start and end indicies. Assume that the start index is less than or equal to the end index. The return value should not include the character at the end_index. The function must use a for loop to traverse the input string and an accumulator to create the return value.

Make sure you have sufficient test cases and that you follow all of the course's coding conventions.

Sample Test Cases

Function Parameters Expected Output
'Hello', 0, 2 'He'
'Hello', 1, 3 'el'
'Hello', 2, 4 'll'

Submission

Submissions for post labs are to be done via the inquire system. Go to http://inquire.roanoke.edu/ You should see a section for post labs. Submit your .py file to the appropriate post lab location.

Post labs are to be done individually. Sharing files between students is not allowed. Doing so is an Academic Integrity violation, and will be treated as such.