- Information
- AI Chat
Was this document helpful?
5. Control and Strings
Course: Computer science1015 (CSC1015F)
257 Documents
Students shared 257 documents in this course
University: University of Cape Town
Was this document helpful?
Version 2024/08/15 08:30:35
Page 1 of 5
CSC1015S Assignment 5
Strings
Assignment Instructions
This assignment involves constructing problems that use input and output, ‘if’ and ’if-else’
control flow statements, ‘while’ statements, ‘for’ statements, and statements that perform string
manipulation.
String concepts: string, index, int( ), str( ), find( ), strip( ), slice, concatenation, iteration over.
NOTE Your solutions to this assignment will be evaluated for correctness and for the following
qualities:
• Documentation
o Use of comments at the top of your code to identify program purpose,
author and date.
o Use of comments within your code to explain each non-obvious functional
unit of code.
• General style/readability
o The use of meaningful names for variables and functions.
• Algorithmic qualities
o Efficiency, simplicity
These criteria will be manually assessed by a tutor and commented upon. In this assignment, up to
10 marks will be deducted for deficiencies.
Question One [10 marks]
Write a Python program called sequence.py which checks if a given string is a subsequence
of another. That is, check if the second string is a subsequence of the first string.
A subsequence of a string is a new string that is formed from the original string by deleting
some (can be none) of the characters without disturbing the relative positions of the
remaining characters. (i.e., "ace" is a subsequence of "abcde" while "aec" is not).
Sample IO (The input from the user is shown in bold font – do not program this):
Enter the full string:
9453923
Enter the subsequence to check for:
493
The given substring is a subsequence of the full string.