- 4
that will ask the user to input a list of numbers and display the input list. Program then find the maximum and second maximum
21 Answers
+ 2
Did you tried anything?
+ 1
This question is asked in viva
+ 1
Take first input as how many elements.
Use for loop for to take numbers one by one.
Keep appending the elements in an empty list
Use print for to print the list.
Use max and min for maximum number and minimum number respectively
+ 1
Nah I won't, you should give it a try first.
+ 1
Nah I don't use social media, you can ask questions here and will get good answers just as mine🙄
(I think so)
0
My computer base is too bad as everything was online
0
"""
WAP that will the ask the user to input a
list of N numbers and then display the input.
Program then find the maximum and second maximum
number in that list and diplay them
"""
#PRIYANSH VERMA XI-C 52
list1=[]
num=int(input("Number Length : "))
for i in range(num):
numbers=int(input("Enter number"))
list1.append(numbers)
print("1 Maximum element in the list is:",max(list1))
print("2 Maximum element in the list is:",list1[-2])
print("Minimum element in the list is:",min(list1))
0
UNABLE TO FIND SECOND LARGEST VALUE
0
list1=[]
num=int(input("Number Length : "))
for i in range(num):
numbers=int(input("Enter number: "))
list1.append(numbers)
list=list1.sort()
print("1 Maximum element in the list is:",max(list1))
print("2 Maximum element in the list is:",list1[-2])
print("Minimum element in the list is:",min(list1))
Priyansh Verma
you should have sorted the list too.🙄
0
What?
0
Is the code working now??
0
It is working but second largest number is not coming out
0
Priyansh Verma
#Test case
Number Length : 4
Enter number: 12
Enter number: 32
Enter number: 12
Enter number: 4
1 Maximum element in the list is: 32
2 Maximum element in the list is: 12
Minimum element in the list is: 4
[Program finished]
0
Thank you so much
0
Dude listen now also it isnt working as 2 largest number is comingout to be 3 when i entered :71,638,3,2728,82
0
I don't think it would be the problem Priyansh Verma, see when I did the same:
Number Length : 5
Enter number: 71
Enter number: 638
Enter number: 3
Enter number: 2782
Enter number: 82
1 Maximum element in the list is: 2782
2 Maximum element in the list is: 638
Minimum element in the list is: 3
[Program finished]
0
😅
0
My bad
0
Ok
- 1
Bro can u pls code it for me