Python List
Python List
using a list.
Solution print('Shreyas soni\n0827CS191224')
n=int(input("enter the valueof n:"))
list=[]
sum=0
for i in range(0,n):
e=int(input())
list.append(e)
for ele in range(0,len(list)):
sum+=list[ele]
print("sum of input no:",sum)
Program 3 Write a program that prompts the user for a list of numbers
and prints out the maximum and minimum of the numbers
at the end when the user enters “done”. Write the program
to store the numbers the user enters in a list and use the
max() and min() functions to compute the maximum and
minimum numbers after the loop completes.
arr.remove(val)
print(arr)
Output Shreyas soni
(Screen 0827CS191224
Shot) Enter 5 Elements:
1
2
3
4
5
[1, 2, 3, 4, 5]
after removal:
[1, 4, 5]
Program 8 Write a Python program to find all the values in a list are
greater than a given number
Solution print('Shreyas soni\n0827CS191224')
list = [200,300,400,500]
num=int(input("enter a no.:"))
for i in range(0,len(list)):
if(list[i]>num):
print(list[i])
max=list[0]
for i in range(0,len(list)):
if(list[i]>max):
max=list[i]
print("max no is",max)