Definitions: A repeatable integer function takes an integer argument and returns
ID: 3745935 • Letter: D
Question
Definitions: A repeatable integer function takes an integer argument and returns a repeatable integer function.
implement repeat, which is a repeatable integer function that detects repeated arguments. As a side effect of repeated calls, it prints each argument that has been used before in a sequence of repeated calls. Therefore, if an argument appears n times, it is printed n-1 times in total, each time other than the first. The detector function is part of the implementation of repeat; you must determine how it is used.
Important: You may not use a list,set,or any other data type not covered yet in the course.
Def repeat(k):
>>>f=repeat(1)(7)(7)(3)(4)(2)(5)(1)(6)(5)(1)
7
1
5
1
“””
return ??? (k)
def detector(f):
def g(i):
if ???:
???
return ???
return g
Explanation / Answer
n = int(input("enter range:"))
numbers = []
duplicate = []
def detector():
for val in numbers:
val_count=0
for i in range(n):
if(val==numbers[i] and duplicate[i]!=0):
val_count=val_count+1
duplicate[i]=0
if(val_count>1):
for j in range(val_count-1):
print(val)
for num in range(n):
numbers.append(int(input()))#taking input
duplicate.append(1)#used later for checking repeat value
detector()
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.