- Create a python file name “BabyNameGenerator2.py”
- Create a list of String variable (“boysName”) with the following value: ‘John’, ‘Peter’, ‘Marcus’, ‘James’, ‘Luke’.
- Create a list of String variable (“girlsName”) with the following value: ‘Abigail’, ‘Martha’, ‘Mary’, ‘Katherine’, ‘Agustine’.
- Create a function called “giveMeBabyName” with one parameter “gender”.
- If “gender” parameter is “boy” then return a random name from “boysName” list. And return that value as a return value of the function.
- If “gender” parameter is “girl” then return a random name from “girlsName” list. And return that value as a return value of the function.
- if everything else then the function should return “InvalidGender”.
- Create a function called “showMeMultipleBabyNames” two parameters: “numOfNames”, “gender”.
- “numOfNames” parameter’s data type is integer which is the number of baby names user want to see.
- call the first function (“giveMeBabyName”) from here. If “numOfNames” is 2 then call “giveMeBabyName” function 2 times and print the return value every time. If “numOfNames” is 3 then call “giveMeBabyName” function 3 times and print the return value every time.
- For example, if I call showMeMultipleBabyNames(3, “boy”), then the program will print like the following
-
John
Peter
Luke
- For example, if I call showMeMultipleBabyNames(2, “girl”), then the program will print like the following
-
Martha
Katherine
- (Added on 01/04/2019) We want to continuously ask user the following until user type “bye”:
- Create a forever loop (while True)
- Inside the loop ask user these 2 questions:
- “Do you want to have girl/boy name? “. Set to variable “gender”.
- “How many names do you want to have? “. Set to variable “numOfNames”.
- If user answer “bye” on any of these questions, break from the forever loop.
- Call showMeMultipleBabyName function and use “numOfNames” as the first parameter and “gender” as the second parameter.