###### tags: `Practice` `List` # List ### Grade Sorter App You are responsible to write an app which accomplishes below tasks - [ ] Get 5 grades from user - [ ] Show grade sorted in ascending order - [ ] Show grade sorted in descending order - [ ] Remove 2 lowest grade and display to user - [ ] Show remaining grade - [ ] Great user and show highest grade ``` python ************************************************************ * Welcome to Grade Sorter App * ************************************************************ What is your first grade (0-100): 10 What is your second grade (0-100): 20 What is your third grade (0-100): 30 What is your forth grade (0-100): 40 Your grades are : [10, 20, 30, 40] Your grade from highest to lowest: [40, 30, 20, 10] The lowest two grades will now be dropped. Removed grade: 10 Removed grade: 20 Your remaining grades are : [40, 30] Nice work! Your highest grade is 40. ``` ### List Types - [ ] Take four list ``` python 'num_strings': ['15', '100', '55', '42'], 'num_ints': [15, 100, 55, 42], 'num_floats': [2.2, 5.0, 1.245, 0.142875], 'num_lists': [[1,2,3], [4,5,6], [7,8,9]] ``` - [ ] For all list - [ ] Print type of list - [ ] Print content of list - [ ] Print type of argument of list ``` python ************************************************************ * Summary Table * ************************************************************ The Variable num_strings is a <class 'list'> It contains the elements: ['15', '100', '55', '42'] The element 15 is a <class 'str'> The Variable num_ints is a <class 'list'> It contains the elements: [15, 100, 55, 42] The element 15 is a <class 'int'> The Variable num_floats is a <class 'list'> It contains the elements: [2.2, 5.0, 1.245, 0.142875] The element 2.2 is a <class 'float'> The Variable num_lists is a <class 'list'> It contains the elements: [[1, 2, 3], [4, 5, 6], [7, 8, 9]] The element [1, 2, 3] is a <class 'list'> Now sorting num_strings and num_ints.. Sorted num_strings: ['100', '15', '42', '55'] Sorted num_ints: [15, 42, 55, 100] ``` ### List Validator App You are responsible to write an app which accomplishes below tasks, use below list to perform the task. ``` python number_list = [ 1,2,3,'r', [ 1, 2, 3, 'S'], { 'color': 'orange' }, ('a', 'b', 'c', 'd'), 'Simple' ] ``` - [ ] Validate all arguements of list. arguements are valid only if its an integer - [ ] Display output in a table format as shown below ``` python index type isvalid 0 <class 'int'> true 1 <class 'int'> true 2 <class 'int'> true 3 <class 'str'> false 4 <class 'list'> false 5 <class 'dict'> false 6 <class 'tuple'> false 7 <class 'str'> false ``` ### List to String Convertor Convert below list to string. ``` python list_to_convert= ['L', 'o', 'r', 'e', 'm'] ``` - [ ] Display converted string and length of string ``` python Converted String:Lorem Length of String:5 ``` ### Split List - [ ] Get length of list from user(n) - [ ] Get n number of inputs from user and create a list - [ ] Slip created list into 2's if n is even else 3's if n is odd - [ ] Display created list and splitted list ``` python Please enter length of list to create: 4 Enter 1st arg: 10 Enter 2nd arg: 15 Enter 3rd arg: 20 Enter 4th arg: 9 Your list : [10,15,20,9] Your splitted list: [[10,5], [20,9]] ```