Answer to Question #300397 in Python for sruthi

Question #300397

can i get code for this

input:

4

2

3

5

7


output:2


with following steps:


Read the Input into a variable.


Now using the loop iterate in range 1 to input.


Again read the second input into the variable.


Now take the count to assign the value 0 to it.


Using loop condition iterate from range 1 to second input.


using the if condition checks the condition that the second input is divisible by number then increment the count.


If the count is equal to 2


print the number and break from the loop.


1
Expert's answer
2022-02-21T01:27:39-0500
n = int(input())
lst = []
count = 0;
for i in range(n):
  x = int(input())
  if x % 2 == 0:
    lst.append(x)
    count = count + 1
for i in lst:
  print(i, end=" ")

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS