DIPLab 1
DIPLab 1
Lab Objective:
Lab Description:
Installation:
Download and install Python interpreter and PyCharm IDE from the following links below.
Python interpreter: https://www.python.org/downloads/
PyCharm IDE: https://www.jetbrains.com/pycharm/download/download-
thanks.html?platform=windows&code=PCC
Setup:
3. Now Right click on the folder and create new python file.
Digital Image Processing Lab Manual
1
Digital Image Processing Lab Manual
2
Digital Image Processing Lab Manual
while number = 23
Repeats a statement or while number<30:
group of statements while print(number)
a given condition is true number+=1
Lab Tasks:
1:
x = [[1, 2, 3, 4, 5], [21, 22, 23, 24, 25], [31, 32, 33, 34, 35]]
Write python code using python indexing and slicing for the following output. Use
only one print statement for each output.
i. [21, 22, 23, 24, 25]
ii. 3
iii. [32, 33]
iv. [1, 3, 5]
Declare y = [0, 0, 0], now using for loop write average of first list in list ‘x’ on first
index of list y and so on. The print(y) should give the following output
o [3.0, 23.0, 33.0] // average of [1, 2, 3, 4, 5] = 3.0
3
Digital Image Processing Lab Manual
Declare z = [0, 0, 0, 0, 0], now using for loop write average of each index of each
list in ‘x’ on corresponding index of list y. The print(z) should give the following
output
o [17.66, 18.66, 19.66, 20.66, 21.66] // average of [1, 21, 31] = 17.66
2:
x = [1, 3, 5, 6, 7, 8, 6, 1, 2, 3]
y = [0, 0, 0, 0, 0, 0, 0, 0]
Write python code using while loop that write average of first three items on first
index of y and so on. The print(y) should give the following output
o [3.0, 4.666666666666667, 6.0, 7.0, 7.0, 5.0, 3.0, 2.0]
Define a function that takes list as argument and returns the average of it. Then
calculate the average of x and y.
Home Tasks:
Write a code that takes two integers from user as input and store in x and y variables. Now generate
a list (w) of x elements and each element contains y random integers ranging from 1 to 10 and
display this list.
Now ask user to enter a number from 1 to 10 and display the number of times that
integer occurs in the whole list (w).
Write a code that calculate mean, median and mode of the list (w).
Write a code that make another list (u) of same dimensions and compare each number
of original list (w) with the average of it calculated in the previous part, if the number
is less than the average, the code should place 0 on the corresponding index in newly
created list (u) else it should place 10. Display the list (u).
THINK!!