0% found this document useful (0 votes)
4 views3 pages

Python List Operations and Scripts

The document contains Python scripts that demonstrate various operations on lists, including finding the maximum and minimum values, calculating the sum and average of elements, checking for the presence of a number, and identifying duplicates along with their counts. Each script is provided with a sample list and includes print statements to display the results. The document serves as a practical guide for basic list manipulations in Python.

Uploaded by

kvvgrvidyalaya
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views3 pages

Python List Operations and Scripts

The document contains Python scripts that demonstrate various operations on lists, including finding the maximum and minimum values, calculating the sum and average of elements, checking for the presence of a number, and identifying duplicates along with their counts. Each script is provided with a sample list and includes print statements to display the results. The document serves as a practical guide for basic list manipulations in Python.

Uploaded by

kvvgrvidyalaya
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

PYTHON LISTS

Q1. Write Python script to display the element with maximum value from the
given list.

Show/Hide Program

list=[11,12,34,77,99,34,23,22]

a=max(list)

print(a)

Q2. Write Python script to display the element with minimum value from the
given list.

Show/Hide Program

list=[11,12,34,77,99,34,23,22]

b=min(list)

print(b)

Q3. Write Python script to display the sum of elements from the given list of
numbers.

Show/Hide Program

list=[11,12,34,77,99,34,23,22]

n=0

m=len(list)

for i in list:

n=n+i

print(list)

print("sum of the list elements is",n)


Q4. Write Python script to display the average of elements from the given list
of numbers.

Show/Hide Program

list=[11,12,34,77,99,34,23,22]

n=0

m=len(list)

for i in list:

n=n+i

print(list)

print("Average of the list elements is", n/m)

Q5. Writ a Python script to input a list of numbers and a number. Check
whether the given number is present in the list or not.

Show/Hide Program

a=eval(input(“enter a list “))

b=eval(input(“enter a number”))

flag=0

for i in a:

if i!=b:

continue

else:

flag=1

if flag==1:

print(“present”)

else:

print(“not present")
Q6. Write a Python script to input a list and find all duplicates and display
number of times they are present in the list.

Show/Hide Program

a=input(“enter a list”)

r=max(n)

for I in range(r+1):

c=[Link](I)

if c!=0:

print(I, “has appeared “,c ,”times in the list”)

You might also like