Respuesta :
Answer:
def find(lst):
max = lst[0]
min = lst[0]
total_even = 0
total_odd = 0
for x in lst:
if(max < x):
max = x
if(min > x):
min = x
if(x%2 == 0):
total_even += 1
else:
total_odd += 1
print("Maximum = ", max)
print("Minimum = ", min)
print("total even =", total_even)
print("total odd =", total_odd)
print("total: ",end="")
temp = 0
for x in lst:
temp += x
print(temp, end=" ")
pre = lst[0]
i = 1
print("\n Close duplicates: ",end="")
while i<len(lst):
flag = False
while(pre == lst[i] and i<len(lst)):
pre = lst[i]
i += 1
flag = True
if(flag):
print(pre,end=" ")
pre = lst[i]
i += 1
print("\n\n\n")
find([1, 3, 3, 4, 5, 5, 6, 6, 6, 2])
find([1, 7, 2, 9])
Explanation:
- Check if a number is even or odd by taking a mod with 2.
- Display all the counts of even, odd, maximum, minimum numbers.
- Run a while loop until pre == lst[i] and i<len(lst) and mark the flag as True.
- Call the find function.
The python 3 program written below performs all the stated functions required in the question :
t = input('Enter values : ')
#takes inputs from user
mylist = [int(x) for x in t.split()]
#reads the inputs into a list
cum_total =0
total = []
even = 0
odd = 0
#initialize containers to hold our variables
print(min(mylist), max(mylist))
#displays the minimum and maximum values in the list.
for num in mylist:
#iterate through the values in the list
cum_total+=num
#takes the Cummulative sum
total.append(cum_total)
#append to the list
if num%2 == 0:
#checks for even values
even+=1
#increases count by 1
else:
odd+=1
print('number of even', even)
print()
print('number of odd', odd)
print()
print(total)
#displays the values required.
Learn more : https://brainly.com/question/25103873