def main():
print( count_vowels("") ) # 0
print( count_vowels("aaa") ) # 3
print( count_vowels("AEIOU") ) # 5
print( count_vowels("cysts") ) # 0
main()
Module 5 Assignments
Short Project 04
Due date: Oct 4, Friday at 7pm
Short Programming projects are submitted during our weekly 45-minute in-person lab sessions. Each lab sessions is guided by two TAs. The instructions for the short project will be available only during the lab sessions. To schedule your lab session go to the weekly lab session spreadsheet.
Programming Problems
Programming Problems should be submitted to gradescope.
Programming Problem 9
Due date: Oct 3, Thursday at 7pm
Write a Python function that does the following:
- Its name is
count_vowels
- It takes one string as argument
- It counts how many vowels there are in the string using a
while
loop - It returns an integer representing the number of vowels (
a
,e
i
,o
,u
– both lowercase and uppercase) found in the argument - You can (and should) use the operator
in
- You are not allowed to use built-in count methods or functions
Name the program vowels.py
. Make sure that gradescope gives you the points for passing the test cases.
Test cases for development:
Programming Problem 10
Due date: Oct 3, Thursday at 7pm
Write a Python function that does the following:
- Its name is
reverse_string
- It takes one string as argument
- Using a
while
loop, it builds a new string that is the reverse of the original string - It returns the reversed string
Write a Python function that does the following:
- Its name is
remove_spaces
- It takes one string as argument
- Using a
while
loop to create a string with no spaces - Return the news string with no spaces
Write a Python function that does the following:
- Its name is
is_palindrome
- It takes one string as argument
- It checks whether the string is a palindrome. A Palindrome reads the same backward and forward. For example: madam, and nurses run
- It returns
True
if the string is a palindrome, andFalse
otherwise - Use your
remove_spaces
function to remove spaces from the argument before you check if the string is a palindrome - Use your
reverse_string
function to reverse the string and then compare the result to the original string
Name the program palindrome.py
. Make sure that gradescope gives you the points for passing the test cases.
def main():
print( reverse_string("aeiou") ) # uoiea
print( remove_spaces("ae io ua") ) # aeioua
print( is_palindrome("noon") ) # True
print( is_palindrome("deified") ) # True
print( is_palindrome("go deliver a dare vile dog") ) # True
main()