- 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

8th Mar 2022, 5:08 AM
Priyansh Verma
21 odpowiedzi
+ 2
Did you tried anything?
8th Mar 2022, 5:20 AM
NEZ
NEZ - avatar
+ 1
This question is asked in viva
8th Mar 2022, 5:21 AM
Priyansh Verma
+ 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
8th Mar 2022, 5:26 AM
NEZ
NEZ - avatar
+ 1
Nah I won't, you should give it a try first.
8th Mar 2022, 6:40 AM
NEZ
NEZ - avatar
+ 1
Nah I don't use social media, you can ask questions here and will get good answers just as mine🙄 (I think so)
8th Mar 2022, 7:00 AM
NEZ
NEZ - avatar
0
My computer base is too bad as everything was online
8th Mar 2022, 5:28 AM
Priyansh Verma
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))
8th Mar 2022, 6:41 AM
Priyansh Verma
0
UNABLE TO FIND SECOND LARGEST VALUE
8th Mar 2022, 6:42 AM
Priyansh Verma
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.🙄
8th Mar 2022, 6:46 AM
NEZ
NEZ - avatar
0
What?
8th Mar 2022, 6:47 AM
Priyansh Verma
0
Is the code working now??
8th Mar 2022, 6:47 AM
NEZ
NEZ - avatar
0
It is working but second largest number is not coming out
8th Mar 2022, 6:48 AM
Priyansh Verma
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]
8th Mar 2022, 6:49 AM
NEZ
NEZ - avatar
0
Thank you so much
8th Mar 2022, 6:50 AM
Priyansh Verma
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
8th Mar 2022, 6:52 AM
Priyansh Verma
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]
8th Mar 2022, 6:56 AM
NEZ
NEZ - avatar
0
😅
8th Mar 2022, 6:57 AM
Priyansh Verma
0
My bad
8th Mar 2022, 6:57 AM
Priyansh Verma
0
Ok
8th Mar 2022, 7:01 AM
Priyansh Verma
- 1
Bro can u pls code it for me
8th Mar 2022, 5:27 AM
Priyansh Verma