You are on page 1of 2

myFile = open("sample.

txt", mode="a+")

ListSize = int(input("Enter the desired size of a list"))

lst = []

Listmul=1

Listavgi=0

count=0

for i in range(0,ListSize):

print("Enter the", i+1, "element of the list:")

ele=int(input())

lst.append(ele)

print("Afetr the", i+1, "element the list is:",lst)

for i in lst:

count+=1

Listmul*=i

Listavgi+=i

Listavg=Listavgi/count

print("Total Elements in the list are:", count, file=myFile)

print("Multiplication is:", Listmul, file=myFile)

print("Average is:", Listavg, file=myFile)

print("Max Element is:", max(lst), file=myFile)

print("Min Element is:", min(lst), file=myFile)

print("By using Loo and IF statements", file=myFile)

smallest = largest = lst[0]

min_position = max_position =0

for j in range(1, ListSize):

if(smallest > lst[j]):

smallest = lst[j]

min_position = j

if(largest < lst[j]):

largest = lst[j]

max_position = j
print("The Smallest Element in this List is : ", smallest, file=myFile)

print("The Index position of Smallest Element in this List is : ", min_position, file=myFile)

print("The Largest Element in this List is : ", largest, file=myFile)

print("The Index position of Largest Element in this List is : ", max_position, file=myFile)

print("-------------End of current execution--------", file=myFile)

myFile.close()

You might also like