Question: python code #python_code python.... Python problem. #python its super urgent,help me guys. As soon As possible.i will be forever grateful to you. Question-3: Write a
python code
#python_code python.... Python problem. #python its super urgent,help me guys. As soon As possible.i will be forever grateful to you.
Question-3: Write a function name "randValues0to9" that takes a string from the user as an argument and generates a random integer between 0 to 9. To generate a random value you need a seed. As your range is 0 to 9, by doing seed%(9+1), you will get a random value between 0 to 9. To generate the seed, you need to count the number of vowels and consonants in that argument. If the vowels are less in number than the consonants, then your seed will be seed = no_of_vowels*no_of_consonants+21. Otherwise, your seed will be seed = no_of_vowels*no_of_consonants+57 Function Calli: randValuesoto 9("H@#ello Peter!!") Sample Output1: Vowels: 4 Consonants: 6 Seed: 45 Random value: 5 Explanation1: In "H@#ello Peter!!": string, there are 4 vowels and 6 consonants. So the vowels are less in number than the constants and the seed is, seed = no_of_vowels*no_of_conostants+21 => seed = 4*6+21 = 45 As your seed is 45, your random value is 45%10 = 5 Function Call2: randValuesoto9("Ayeeeeeeeeeeeee imao") Sample Output2: Vowels: 16 Consonants: 3 Seed: 105 Random value: 5 Explanation2: In "Ayeeeeeeeeeeeee Imao" string, there are 16 vowels and 3 consonants. So the vowels are more in number than the constants and the seed is, seed = no_of_vowels*no_of_conostants+57 => seed = 16*3+57 = 105 As your seed is 105, your random value is 105%10 = 5
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
