Questions on LIST in Python

List in Python
  1. Declare one blank list and then add four items to it.
    my_list=[]
    my_list.append('Alex')
    my_list.append('Ronn')
    my_list.append('Geek')
    my_list.append('Rabi')
    
  2. Declare one list by using one integer , one float and two strings.After adding display 2nd element and check the data type of the list.
    my_list=['Alex',4,'Ronn',6.54]
    print(type(my_list))
    print(my_list[2])
  3. Create one list by using output of a range. Example : your list should have all the numbers starting from 5 to less than 50 with increment of 5.
    x=range(5,50,10)
    my_list=list(x)
    print(my_list)
  4. Display all items of a list by looping
    my_list=[2,4,1,2,4,5,3]
    for i in my_list:
      print(i)
  5. Display last item
    my_list=[2,4,1,2,4,5,3]
    print(my_list[-1])
  6. Display 2nd item from last
    my_list=[2,4,1,2,4,5,3]
    print(my_list[-2])
  7. All items starting from 0 till last
    my_list=[2,4,1,2,4,5,3]
    print(my_list[0:])
  8. All items starting from 1 till last
    my_list=[2,4,1,2,4,5,3]
    print(my_list[1:])
  9. All items starting from 2 to 4
    my_list=[2,4,1,2,4,5,3]
    print(my_list[2:4])
  10. Create one list with names of your five friends. Return the position of your best friend in the list.
  11. Add one name Alex to above list. ( append())
  12. Add name ‘Ronn’ to 2nd position ( insert()).
  13. Create two list and then merger 2nd list with first list and display the output ( extend() )
  14. Create a copy of your friends list
  15. Remove one element from the list ( specify the name )
  16. Remove the 2nd element from the list and display the removed element ( use pop() )
  17. Remove all the elements of a list.
  18. Create a list using names of your friends, then search for your best friend name inside the list ( use in )
  19. Find the total number of elements present in a list ( use len() )
  20. Find the number of time one particular element is present inside (use count() )
  21. Reverse the order of the list and then print
  22. Sort a list then print
  23. Create a list of your friends and sort them in the order of their length.
  24. In above list reverse the sorting order
  25. Create one list and remove duplicate elements from it.
  26. Find the sum of all elements of a list with integers as elements.
  27. Find the highest and lowest number of a list
  28. What is the difference between append() and insert() methods?
  29. What is the difference between append() and extend() methods?
  30. Take one input string and create one list by using all the chars of the string.
  31. In above list remove the duplicate chars
  32. Find the common elements between two lists.
Python- Multi dimensional List Matrix Multiplication without using built-in functions Python- List append



plus2net.com



Post your comments , suggestion , error , requirements etc here





Python Video Tutorials
Python SQLite Video Tutorials
Python MySQL Video Tutorials
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
©2000-2021 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer