Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help in completing this code fully with comments! I'm having trouble starting. Program Specifications Write a program that asks the user for a string

Please help in completing this code fully with comments! I'm having trouble starting.

image text in transcribed

Program Specifications Write a program that asks the user for a string of lowercase letters and numbers. The program should evaluate the string and report the number of vowels ('a', 'e','', 'o', 'u' and numbers ('0','1','2',3, 4, '5', '6', '7', '8', '9') in the string. Sample run The user input is abc123 Enter a string: abc123 Total vowels: 1 Total numbers: 3 Required program decomposition We will not specify the decomposition to follow for this lab. However, the last test case will check that each function contains at most six lines of code. This six-line limit includes the function definition line. Comment lines or empty lines don't count toward the six-line limit. Consider separating out the tasks to check if a character is a vowel and if a character is a number. Also separate out the task of counting the number of vowels and counting the number of numbers. It is possible that two functions may be very similar, which is okay as long as they are doing two different things. Notes All statements must be part of a function definition. You must only use features of Python that have been described in class. Remember that strings are also sequences just like lists. You can process a string one character at a time just as you would process a list one element at a time. You may copy the is_vowel function described in class. Since any letters in the string that will be inputted by the user will be all lowercase, the is_vowel function can be simplified to the following: def is vowel (ch): return (ch == 'a' or ch == 'e' or ch == 'i' or ch == 'o' or ch == 'u') An integer is different from a character representing the same number. That is, 1 == '1' will return false. When comparing numbers in the string, make sure you are comparing the string 'l' instead of the integer 1. You may consider writing a function similar to is vowel to check for numbers. Style guidelines Be sure you are following to the programming style guidelines as outlined in the CS 1104 Style Guide document, which can be found on Brightspace under Content Course Documents. Note on Spyder For at least the Windows version of Spyder, an extra empty line is printed before every call to the input function, whereas in zyBook or other Python IDEs, the empty line isn't supposed to be there. This bug has been noted to the developers of Spyder, but has not been resolved. For example, the code: print('A line.') input('A prompt: ') will output in Spyder: A line. A prompt: Notice the extra empty line in the middle. The correct output should have been: A line A prompt: Please note this buggy behavior on Spyder and write your code as if the line was not there i.e., in the example two-line code above, there won't be an extra line in- between the outputs)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Building Database Driven Catalogs

Authors: Sherif Danish

1st Edition

0070153078, 978-0070153073

More Books

Students also viewed these Databases questions

Question

Describe the appropriate use of supplementary parts of a letter.

Answered: 1 week ago