Scientific Computing
Create a file named activity14.py
and save it to your cs100/ch3
directory.
countCharacterTypes(myString)
that takes a string as a parameter. It will count and print the number of uppercase characters, lowercase characters, digits, and symbols (non-alphanumeric characers). Test your function by calling it. For example, calling the function countCharacterTypes("Here.123 is EXAMPLE !!^&*")
should print out:
Number of uppercase characters: 8
Number of lowercase characters: 5
Number of digit characters: 3
Number of symbol characters: 9
Number of uppercase characters: 8
Number of lowercase characters: 5
Number of digit characters: 3
Number of symbol characters: 9
allOccurrences(myString, character)
which takes a string as the first parameter and a single character as the second parameter. It should print all indices where the given character is found in myString. Hint: use a for loop. Test your function by calling it. For example, the function call allOccurrences("Here is an example string", 'e')
would produce the following output:
1
3
11
17
reverseString(myString)
to reverse the given string and return it. Use a for loop to solve this problem. Test your function. For example, print(reverseString("scientific computing"))
will output gnitupmoc cifitneics
.Submit your working python file to Moodle.