Question

PYTHON REQUIRED Bonus (4 points): Why was 6 afraid of 7? Because 7 89! Actually, this is mathematically impossible. Cannibal numbers as theyre called can only eat numbers that are smaller than them, or the same size. After eating another number, the number that gets eaten disappears, and the number that ate them increases by 1 For example, given the following set of numbers, lets pretend that 9 is the cannibal. 127, 9,3, 8, 11] 9 could start by eating 3 or 8. Lets say it eats 3, then the numbers would be: [27, 10, 8, 11) Then it could eat 8, so the numbers would be: [27, 11, 11] And lastly, it could eat 11 (27, 12] Your task is to write a program that, given a list of numbers and a target number, determines how many numbers in the list can become exactly that number For instance, in our example, two numbers could reach the value of 10. As we saw, 9 took on that value in the example. However, if 8 were the cannibal, it could .Eat 3 to become 9 Eat 9 to become 10 So it could also hold the value of 10 For a target value of 11, the answer would also be 2, because 9 can become 11, and 11 is already 11 Your function may be passed a string of values separated by commas instead of a list--1 out of 4 points will be awarded for handling this case correctly [ ]: Write your answer here. ]: 3, 8, 11], 11) 2 9, [1: cannibal([27, 9, 3, 8, 11, 50) 0 3, [ cannibal ( [27, [ ]: cannibal ( [3, 3, 2, 2, 2, 1, 1, 1], 4) 9 [ ]: cannibal ( 1,2,3,4,5, 5) -4

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Solulior → If function sigrodu re is like -anni Cncmst ing, tauget) thern arget Use string sph ㅏ tuncT,on to convert num ingn ele o evey num and check i the no. inner ?tin an Cooer eyer neam e Smaller than oter loo vanable value

Add a comment
Know the answer?
Add Answer to:
PYTHON REQUIRED Bonus (4 points): Why was 6 afraid of 7? Because 7 89! Actually, this...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • test cases cannibal([27, 9, 3, 8, 11], 11) == 2 cannibal([27, 9, 3, 8, 11], 50)...

    test cases cannibal([27, 9, 3, 8, 11], 11) == 2 cannibal([27, 9, 3, 8, 11], 50) == 0 cannibal([3, 3, 3, 2, 2, 2, 1, 1, 1], 4) == 9 cannibal("1,2,3,4,5", 5) == 4 Because 7 8 9! Actually, this is mathematically impossible. "Cannibal numbers" as they're called can only eat numbers that are smaller than them, or the same size. After eating another number, the number that gets eaten disappears, and the number that ate them increases by 1...

  • 1. use python List to Dictionary Write a function that has three parameters: a list of...

    1. use python List to Dictionary Write a function that has three parameters: a list of unsorted numbers with no duplicates, a start number, and an end number. This function should return a dictionary with all integers between the start and end number (inclusive) as the keys and their respective indices in the list as the value. If the integer is not in the list, the corresponding value would be None. Example unsorted list: [2,1,10,0,4,3] two numbers: 3, 10 returned...

  • This is a python work, thank for helping! 7. (6 points) Write a function, countOfAndSmalest Number...

    This is a python work, thank for helping! 7. (6 points) Write a function, countOfAndSmalest Number Between(low, high, ignore, listOfNumbers), that takes as input three numbers and a list of numbers, and returns a list containing two items: 1) how many items in listOfNumbers are greater than low, less than high, and not equal to ignore 2) the smallest number in listOfNumbers that is greater than low, less than high, and not equal to ignore (or None if there is...

  • Python Language Only!!!! Python Language Only!!!! Python Language Only!!!! Python 3 is used. A. Write a...

    Python Language Only!!!! Python Language Only!!!! Python Language Only!!!! Python 3 is used. A. Write a function named smaller that accepts two arguments: a list, and a number n. Assume that the list contains numbers. The function should display all numbers in the list that are smaller than the number n. Write a code that declares and initializes a list of numbers and a variable number and pass them to the function to test it. Please see the outcome below:...

  • Python Language Only!!!! Python Language Only!!!! Python Language Only!!!! Python 3 is used. A. Write a...

    Python Language Only!!!! Python Language Only!!!! Python Language Only!!!! Python 3 is used. A. Write a function named smaller that accepts two arguments: a list, and a number n. Assume that the list contains numbers. The function should display all numbers in the list that are smaller than the number n. Write a code that declares and initializes a list of numbers and a variable number and pass them to the function to test it. Please see the outcome below:...

  • Python Language Only!!!! Python Language Only!!!! Python Language Only!!!! Python 3 is used. A. Write a...

    Python Language Only!!!! Python Language Only!!!! Python Language Only!!!! Python 3 is used. A. Write a function named smaller that accepts two arguments: a list, and a number n. Assume that the list contains numbers. The function should display all numbers in the list that are smaller than the number n. Write a code that declares and initializes a list of numbers and a variable number and pass them to the function to test it. Please see the outcome below:...

  • Python Language Only!!!! Python Language Only!!!! Python Language Only!!!! Python 3 is used. A. Write a...

    Python Language Only!!!! Python Language Only!!!! Python Language Only!!!! Python 3 is used. A. Write a function named smaller that accepts two arguments: a list, and a number n. Assume that the list contains numbers. The function should display all numbers in the list that are smaller than the number n. Write a code that declares and initializes a list of numbers and a variable number and pass them to the function to test it. Please see the outcome below:...

  • using Python --- from typing import List THREE_BY_THREE = [[1, 2, 1], [4, 6, 5], [7,...

    using Python --- from typing import List THREE_BY_THREE = [[1, 2, 1], [4, 6, 5], [7, 8, 9]] FOUR_BY_FOUR = [[1, 2, 6, 5], [4, 5, 3, 2], [7, 9, 8, 1], [1, 2, 1, 4]] UNIQUE_3X3 = [[1, 2, 3], [9, 8, 7], [4, 5, 6]] UNIQUE_4X4 = [[10, 2, 3, 30], [9, 8, 7, 11], [4, 5, 6, 12], [13, 14, 15, 16]] def find_peak(elevation_map: List[List[int]]) -> List[int]: """Return the cell that is the highest point in the...

  • please answer 1-5 Section 4. Write the following programs. (34 points) 1. (7 points) Define a...

    please answer 1-5 Section 4. Write the following programs. (34 points) 1. (7 points) Define a class called MyLinkedQueue containing two data field: head and tail. Create constructors, setters and getters as appropriate. 2. (7 points) Define an inner class called Queue Node inside MyLinkedQueue containing necessary data fields, and constructors, to make sure the queue can move back and forth. 3. (10 points) Implement the poll and offer methods for the MyLinkedQueue class. 4. (5 points) Implement the isPalindrome...

  • Could anyone help add to my python code? I now need to calculate the mean and...

    Could anyone help add to my python code? I now need to calculate the mean and median. In this programming assignment you are to extend the program you wrote for Number Stats to determine the median and mode of the numbers read from the file. You are to create a program called numstat2.py that reads a series of integer numbers from a file and determines and displays the following: The name of the file. The sum of the numbers. The...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT