Question: ********PYTHON******** Write a function called name_facts that will take a firstname (string) as an input parameter, and print out various facts about the name, including:

********PYTHON********

Write a function called name_facts that will take a firstname (string) as an input parameter, and print out various facts about the name, including: 1) its length, 2) whether it ends with the letter R, 3) how many of its letters are vowels (NOTE: not the number of unique vowels, but the total number of vowels), and 4) whether it contains a Q. To gain full credit for this exercise, you must use string formatting to print out the result.

Hints:

You will probably want to convert the string to lowercase when checking conditions 2-4. You can get by without it, but you'll have to make sure you check both lower and uppercase versions of the letters

You will have to use the in operator for condition 3 and 4

You will probably want to use an algorithm like this for condition 3:

define a variable num_vowels and initialize it to 0 for character in name: if character is in `aeiou`, add 1 to num_vowels 

You will also probably want to make a separate message for each condition (depending on the answer) and use string formatting to join them into the final message

Example output:

Given "Allegra" as input: Your name is 7 letters long, does not end with the letter S, contains 3 vowels, and does not contain a Q or Y

Given "Xander" as input: Your name is 6 letters long, does end with the letter R, contains 2 vowels, and does not contain a Q or Y

Given "Queen" as input: Your name is 5 letters long, does not end with the letter R, contains 3 vowels, and does contain a Q or Y

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!