Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In English, the indefinite article has two forms: a (used when the first sound of the following word is a consonant) and an (used, roughly

image text in transcribedimage text in transcribed

In English, the indefinite article has two forms: a (used when the first sound of the following word is a consonant) and an (used, roughly speaking, when the first sound of the following word is a vowel). As an oversimplification of how to make this distinction, let's assume that an should be used when the first letter of the word it precedes is one of a, e, i, o and u, and a should be used otherwise. Write a program that asks the user to enter a phrase, and prints out that phrase preceded by an (with a space) if the phrase starts with a vowel, and a (with a space) for all other inputs (including the empty string). Your program should work like this: 1 Enter a phrase: aardvark an aardvark 2 3 1 Enter a phrase: banana a banana 2 3 1 Enter a phrase: Australian an Australian 2 w N 3 Note that, based on our simple heuristic, the method will produce some outputs which are more dubious sounding, such as: 1 Enter a phrase: honour a honour 2 3 1 Enter a phrase: unicorn an unicorn 2 3 Hint One string method that you might find useful is . lower(), which returns a copy of the string that it is called from, converted to lower case, e.g.: print("Apologies to Chekov". lower()) 8 Index Errors If you're having trouble with Index Errors for one of the test cases, have a read back over the problem description and think about whether your code has asked for an element of a string which might not exist. For example: my_string = "abc" print(my_string[5]) How might you test for this to ensure the error-causing code doesn't run

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_2

Step: 3

blur-text-image_3

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

Visual Basic Net Database Programming

Authors: Rod Stephens

1st Edition

0789726815, 978-0789726810

More Books

Students also viewed these Databases questions