- Engineering
- Computer Science
- function name magicball parameters age int name string...
Question: function name magicball parameters age int name string...
Question details
Function name : magic_ball()
Parameters : age (int), name (string), year in school (int)
Returns: an int
Description : You go to a magic shop because you want your fortune for this semester. The fortune teller says she’ll predict your fortune based on the number that the magic ball generates for you. Little does she know, the magic ball generates your number based on some of your personal traits! Write a function called magic_ball that calculates a number that represents your luck for this semester. Calculate the number by adding the age, the length of the name, and the year together. If the value is greater than or equal to 30, return 3. If the value is greater than or equal to 10 but less than 30, return 2. Otherwise, return 1.
Note: aStr = “String!” a = len(aStr) #len(aStr) gives you the length of the string as an integer #a is equivalent to 7 which is the length of aStr
Solution by an expert tutor
