filmov
tv
List Data Type | Indexing | Slicing | Append - Extend - Insert - Closer look at python data types

Показать описание
In this video we will discuss how to define a lists in python. Concept of indexing and slicing in list. We will also discuss the built in methods to add the elements to the list.
Practice Problem on Data Type :
1 ) Write a program that takes two di?erent lists, and returns the smallest value that appears in both lists.
For example, given the lists l1,l2,l3
l1 = [ 1, 3, 8, 12, 12, 15, 20 ]
l2 = [ 7, 9, 10, 11, 15, 30, 35 ]
l3 = [ 2, 4, 5, 13, 16, 17, 23, 25 ]
then
print smallest_in_common(l1,l2) # should output 15
print smallest_in_common(l1,l3) # should output None
2) Write Python code that takes a list of numbers, and outputs the positive values that are in v in increasing order, If there are no positive values, then the output should be None.
For example, l = [ 17, -5, 15, -3, 12, -5, 0, 12, 22, -1 ]
Then the output of your code should be
[12,12,15,17,22]