These functions descriptions are included here for you to have them separately for reference; however, these descriptions will appear to you directly when working with CodeWrite
1. Function:
def blastoff(n)
Description:
This function receives as an input argument an integer number, which we call n. If the number is not negative, the function should return a string, which will have the number n, followed by two points, then the number (n -1), followed by two points, then the number (n -2), and two points and so on until reaching the number '0', followed by two points. Then the string should end with exactly two exclamation signs ‘!!’ If the number is negative, the function should return two exclamation signs.
An example:
stringNumsPoints(5) should return '5..4..3..2..1..0..!!'
2. Function:
def whichPositionsRev (originalStr, ch)
Description:
Given a string (st) and a character (ch) as input, this function should return a new string.
The returned string should have the word ‘No’ if the character is not found in the original
string, neither in lower case nor in upper case. On the other hand, if the character is in the original string, either in lower or upper case, the function should return a string containing the word ‘Yes’, then (with no space in between) three dots ‘…’ and then the new string should have all the positions where the character is in the original string, in reverse order as they are found in the string. The positions should be in the resulting string with one space in between and one space at the end.
For example:
whichPositionsRev('abc!abc!ABC!', '$') should return 'No'
whichPositionsRev('abc!abc!ABC!', 'a') should return 'Yes...8 4 0 ' CMPT 120, Page 2 of 4
3. Function:
def countLetters (st)
Description:This function should count how many letters there are in the input string st, starting to count (including in the count if it is a letter) from position 0 and advancing one position at a time until reaching the end of the string. The string may contain letters, digits and also special characters.
countLetters('12abc!#456') should return 3
countLetters('abc123de') should return 5
An example:
countLetters('12abc!#456') should return 3
4. Function:
def countLettersFromPosUntilDigit (st, pos)
Description:
This function should count how many letters there are in the input string st, starting to count from position pos (counting the character in pos if it is a letter) and advancing one position at a time until encountering a digit or until reaching the end of the string. The string may contain letters, digits and also special characters. If pos is not a valid position in the string, the function should return 0.
For example:
countLettersFromPosUntilDigit('12abc!#456',0) should return 0
countLettersFromPosUntilDigit('abc!#456',1) should return 2
countLettersFromPosUntilDigit('123abc',3) should return 3
countLettersFromPosUntilDigit('abc123de',0) should return 3
Hint: you may want to use a for loop and a 'flag variable ', You may also use while loops.