1.
count = 0
while count < 5:
print("1", end=" ")
count+=1
OUTPUT;
2.
count = 1
while count <= 5:
print(count, end=" ")
count+=1
OUTPUT;
3.
while count <= 9:
print(count, end=" ")
count+=2
OUTPUT;
4.
count = 3
while count <= 15:
print(count, end=" ")
count+=3
OUTPUT;
5.
count = 15
while count >= 3:
print(count, end=" ")
count-=3
OUTPUT;
6.
count = 10
while count >= 2:
print(count, end=" ")
count-=2
OUTPUT;
7.
count = 9
while count >= 1:
print(count, end=" ")
count-=2
OUTPUT;
8.
count = 1
while count <= 100:
if count % 3 == 0 and count % 5 == 0:
print(count)
count+=1
OUTPUT;
9.
count = 1
while count <= 100:
if count % 3 == 0 or count % 5 == 0:
print(count)
count+=1
OUTPUT;
10.
givennumber = 15
count = 1
while count <= givennumber:
if givennumber % count == 0:
print(count)
count+=1
OUTPUT;
11.
givennumber = 15
count = 1
total = 0
while count <= givennumber:
if givennumber % count == 0:
print(count)
total+=count
count+=1
print("total :",total)
OUTPUT;
12.
givennumber = 15
count = 1
total = 0
while count <= givennumber/2:
if givennumber % count == 0:
print(count)
total+=count
count+=1
if total == givennumber:
print("perfect number because total and givennumber are same")
else:
print(" not a perfect number,because total and givennumber are not same")
output;
13.
givennumber = 37
if givennumber < 2:
print("not a prime number")
else:
count = 2
while count <= givennumber//2:
if givennumber % count == 0:
print("not a prime number")
break
count += 1
else:
print("prime number")
OUTPUT;
14.
references
https://dev.to/sivakumar_mathiyalagan_/python-exercise-37cg









Top comments (0)