Question
In Python English words are composed of consonants and vowels. In most programming languages, words are represented with strings. Let us define the ratio of
In Python
English words are composed of consonants and vowels. In most programming languages, words are represented with strings. Let us define the ratio of the number of consonants to number of vowels in a string as its K-value. The K-value for the string Jon Doe = 3/3 = 1. When calculating this value, we ignore case differences and any non-english letters. For a second example, the K-value for the string Jane Doe = 3/4 = 0.75.
Let us also define the string length as the total number of alphabetic characters. Thus the length of the string Jon Doe is 6, and for Jane Doe it is 7.
Here is a starter program that computes and prints the k-value for Jane Doe:
# values for Jane Doe num_consonants = 3 num_vowels = 4
# compute length and k_value length = num_consonants + num_vowels k_value = num_consonants / num_vowels
# print the k-value print(k_value:,k_value)
# write the if-else blocks below to complete your project
For this project, extend the above program to :
If K-value < 1.69 and length >= 12, print this as output: (length * number of consonants) If K-value < 1.69 and length < 12, print this as output: (length * number of vowels) If K-value >=1.69 and length >=12, print this as output: (length+number of consonants) If K-value >=1.69 and length < 12, print this as output: (length+number of vowels)
Where: K-value = K-value of your own full name (per registration records), and length = length of your own full name
I just need the overall code to understand how the if/else code works. You can use John Doe for the name to answer the question
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started