Python is commonly used for developing websites and software, task automation, data analysis, and data visualization. Since it's relatively easy to learn, Python has been adopted by many non-programmers such as accountants and scientists, for a variety of everyday tasks, like organizing finances.
LAB 1
lis1=[3,10,9,13,12,15]
lis2=[7,2,1,8]
odd=[]
even=[]
l1=len(lis1)
l2=len(lis2)
print("Main list 1 is : ", lis1)
print("Odd numbers from list 1 : ")
for i in range (0,l1):
if(lis1[i]%2!=0):
odd.append(lis1[i])
print(odd)
print("Main list 2 is : ", lis2)
print("Even numbers from list 2 : ")
for i in range (0,l2):
if(lis2[i]%2==0):
even.append(lis2[i])
print(even)
def add_two(x):
x+=2
return x
print(add_two(2))
LAB 2
For all the numbers 1โ1000, use a nested list/dictionary comprehension to find the highest single digit any of the numbers is divisible by
highest={num: max([divisor for divisor in range(1,10) if num % divisor == 0])
for num in range(1,1001)}
print(highest)