Advance machine learning video lecture pdf
Advance machine learning video lecture pdf
2 * 6 = 12
2 * 5 = 10
5 * 2 = 10
5 * 6 = 30
6 * 2 = 12
6 * 5 = 30
3.This code finds and prints all perfect numbers between 1 and
100.
a=1
while a<=100:
y_sum = 0
for i in range (1,a):
if a%i == 0:
y_sum = y_sum + i
if y_sum == a:
print( "perfect number:" ,a)
a = a+1
Output:
perfect number: 6
perfect number: 28
4. This code compares each element i from list1 with each
element j from list2. If i != j, it prints their product.
st1 = [2,5,6]
list2 = [2,6,5]
result = []
for i in list1:
for j in list2:
if i == j:
continue
Output:
2 * 6 = 12
2 * 5 = 10
5 * 2 = 10
5 * 6 = 30
6 * 2 = 12
6 * 5 = 30
red vegeies
red shirt
black apple
black vegeies
black shirt
pink apple
pink vegeies
pink shir
7. This code prints each character of each fruit name separated
by *.
list_fruits = ["mango","apple","banana"]
for fruit in list_fruits:
for i in fruit:
print(i, end="*")
print( )
Output:
m*a*n*g*o*
a*p*p*l*e*
b*a*n*a*n*a*
*
**
***
****
*****
******
*******
0
1
2
3
4
out from loop
*
**
***
****
*****
******
*******
********
*********
**********
*
**
***
****
*****
******
*******
********
*********
**********