Yes that is correct, but what is the question?
Answer:
def index(elem, seq):
for i in range(len(seq)):
if elem == seq[i]:
return i
return len(seq)
print(index(5, [4, 10, 8, 5, 3, 5]))
Explanation:
Create a function named index that takes elem and seq as parameters
Create a for loop that iterates through the seq. If elem is equal to the item in the seq, return the i, index of the item.
If the elem is not found in the seq, this means nothing will be returned in the loop, just return the length of the seq, len(seq)
Call the function with given parameters and print the result
Note: Since 5 is in the list in the example, the index of the 5 which is 3 will be returned
Answer:
Predict Demand
Explanation:
The type of Artificial Intelligence (Al) solution that would be suitable for solving this problem is "Predict Deman"
By predicting the demand of the potential consumer through the Artificial intelligence solution the retailer would be able to eliminate leftover out-of-stock scenarios because the adequate quantity of the products or demands will be provided thereby enhancing customers' experience arising from out-of-stock scenarios and reducing losses arising from the leftover.
Answer:
Following is the program in Python language
def uniquely_sorted(lst1): #define the function uniquely_sorted
uni_que = [] #creating an array
for number in lst1: #itereating the loop
if number not in uni_que: #check the condition
uni_que.append(number)#calling the function
uni_que.sort() #calling the predefined function sort
return uni_que #returns the unique values in sorted order.
print(uniquely_sorted()([8, 6, 90, 76])) #calling the function uniquely_sorted()
Output:
[6,8,76,90]
Explanation:
Following are the description of the Python program
- Create a functionuniquely_sorted() that takes "lst1" as a list parameter.
- Declared a uni_que[] array .
- Iterating the loop and transfer the value of "lst1" into "number"
- Inside the loop call, the append function .the append function is used for adding the element in the last position of the list.
- Call the predefined function sort(for sorting).
- Finally, call the function uniquely_sorted() inside the print function.
Answer:
2
Explanation:
The system only uses 2 numbers which are 0 and 1 instead of the usual 10 numbers; 0, 1, 2, 3, 4, 5, 6, 7, 8 & 9.