Computer Science, asked by vineetk2705, 1 year ago

Generate the list 'k4' having numbers from 100 to 1 in decreasing order, which are also multiple of 25 in python


supriyakrishnacse: k4=range(100,0,-25)
print(k4)
print(list(k4))

Answers

Answered by sherafgan354
3

Following will be the code to do it

k4=[]

for x in range(1,100):

   if(x%25==0):

       k4.append(str(x))    

k4.reverse()

print(k4)

Now what will this program do:

First of all it will create a list k4 it is empty right now

Now it will start a loop in range 1 to 100

After it it will find out the multiples of 25 and take those numbers and appends them in the list

In the end we reverse the list to get the answers in decreasing form and we print the list

Answered by Arslankincsem
1

The python code generating the list 'k4' having numbers from 100 to 1 in decreasing order, which are also multiple of 25 is following – nl=[] for x in range(100, 1):     if (x%25==0):, nl.append(str(x)), print (','.join(nl)), Sample output- 100, 75, 50, 25.


In the above program two conditions are given. The number should be from 100 to 1. The second condition is that it must be a multiple of 25.

Similar questions