Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

What will be the output for this program?

+1 vote
asked Dec 18, 2019 by Shubham (130 points)
a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];

for(i=0; i<10;i++){

total=0;

temp = a[i]/2;

(for j=1; j<=temp; j++){

if(a[i]%j==0){

total = total + j;

}

}

if (total == a[i]) {

print( a[i] : + "is" + "ABC");

}

else{

print( a[i] : + "is" + "XYZ");

}

}

1 Answer

0 votes
answered Dec 21, 2019 by Stark

CODE :

a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
for i in range(0,10):
    total =0
    temp=a[i]//2
    for j in range(1,temp+1):
        if a[i] % j==0:
            total+=j
    if total==a[i]:
        print(str(a[i])+" is "+"ABC")
    else:
        print(str(a[i]) +" is " + "XYZ")‚Äč

Output :

1 is XYZ
2 is XYZ
3 is XYZ
4 is XYZ
5 is XYZ
6 is ABC
7 is XYZ
8 is XYZ
9 is XYZ
10 is XYZ

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...