Strings
Strings
CSC1015S Assignment 6
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.
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.
Page 1 of 5
Version 23/08/2023 11:35:33
Sample IO (The input from the user is shown in bold font – do not program this):
Enter the full string:
This is me
Enter the subsequence to check for:
sisi
The given substring is not a subsequence of the full string.
Write a program called ‘shiftcypher.py’ that may be used to encode a message using the shift
cypher.
The shift cypher is a simple technique for coding (and decoding) messages. It involves taking each
letter in the original message and replacing it with one that is a set number of places further along
the alphabet (wrapping around from 'z' back to 'a' if necessary). The number by which each letter is
to be "shifted" is called the key.
If the key is 3, for example, this means that an 'a' will be replaced by an 'd', a 'b' by an 'e', and so on.
Sample IO (The input from the user is shown in bold font – do not program this):
Sample IO (The input from the user is shown in bold font – do not program this):
Page 2 of 5
Version 23/08/2023 11:35:33
Write a program called ‘breakup.py’ that accepts a sentence as input and that outputs it
as a comma-separated list of lowercase words with a full-stop at the end.
Sample IO (The input from the user is shown in bold font – do not program this):
Enter a sentence:
Jerusalema ikhaya LAMI
The word list: jerusalema, ikhaya, lami.
HINT
• To make a comma separated list, you should treat the first item as a separate case before
looping for subsequent items i.e. get the first word and print, then for each subsequent
word, print a comma and space then the word.
• To extract a word at a time, use ‘find()’ to look for the next space.
• Keep breaking down the sentence into the first word and the rest of the sentence. The rest
of the sentence becomes the whole sentence for the next iteration.
NOTE
• Please ensure that your solution ONLY uses Python features introduced in lectures.
Page 3 of 5
Version 23/08/2023 11:35:33
Write a program called ‘messageframe.py’ to draw a frame (made of the characters ‘+’, ‘-‘, and
‘|’) around a message that has been repeated on consecutive lines. There is a space before and after
the message, and no spaces between concentric boxes.
Sample IO (The input from the user is shown in bold font – do not program this):
Sample IO (The input from the user is shown in bold font – do not program this):
Page 4 of 5
Version 23/08/2023 11:35:33
Sample IO (The input from the user is shown in bold font – do not program this):
Page 5 of 5