Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python Question: Write a function name randValues0to9 that takes a string from the user as an argument and generates a random integer between 0 to

Python Question:

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 Call1: randValues0to9("H@#ello Pe3ter!!") Sample Output1: Vowels: 4 Consonants: 6 Seed: 45 Random value: 5 Explanation1: In H@#ello Pe3ter!!: 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: randValues0to9("Ayeeeeeeeeeeeee lmao") Sample Output2: Vowels: 16 Consonants: 3 Seed: 105 Random value: 5 Explanation2: In Ayeeeeeeeeeeeee lmao 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

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

Accounting And Auditing Research And Databases Practitioner's Desk Reference

Authors: Thomas R. Weirich, Natalie Tatiana Churyk, Thomas C. Pearson

1st Edition

1118334426, 978-1118334423

More Books

Students also viewed these Databases questions