Coding Assignments ( Python List )- Problems and Solutions
This article contains coding exercises related to python list
NOTE : The solutions are given at the last of this article. But try to write your code before taking the help of the solutions.
Problem 1
Define a function that takes a list containing integers. The function returns a list containing all even integers only present in the provided list.
Example
def foo(mylist):
Body
a = foo([1,2,4,5,7,3,8,3])
print(a) # [2,4,8]
Problem 2
Given a list of numbers (define a list), find and print all its elements that are greater than their left neighbor.
Example
a= [1, 5, 2, 4, 3]
Example output
5 4
Problem 3
Define a function that takes a list containing integers. It returns the the maximum value present in the list and its index.
Example
def foo(mylist):
Body
a = foo([1, 5, 2, 4, 3])
print(a) # 5,1
Problem 4
Define a function that takes a list containing integers. It returns a list containing all integers that appear only once in the given list.
Example
def foo(mylist):
Body
a= foo([1,2,2,3,4,5,6,5])
print(a) # [1,3,4,6]
Solutions
1) Problem 1 - python_list_01 - Replit
2) Problem 2 - python_list_02 - Replit
3) Problem 3 - python_list_03 - Replit
4) Problem 4 - python_list_04 - Replit