10.5k views
2 votes
Write a program that reads a list of integers, and outputs whether the list contains all even numbers, odd numbers, or neither. The input begins with an integer indicating the number of integers that follow.

Ex: If the input is:


5

2

4

6

8

10

the output is:


all even

2 Answers

7 votes

Answer:

integers = []

while True:

number = int(input("Enter integers (Enter negative number to end) "))

if number < 0:

break

integers.append(number)

print ("The smallest integer in the list is : ", min(integers))

print("The largest integer in the list is : ", max(integers))

Step-by-step explanation:

User Doug Fawley
by
5.6k points
6 votes

Answer:

lis=[]

lis=input("Enter a list of integers:")

i=0

for i in range(0, len(lis)):

j=int(lis[i])

if j%2==0:

print(j, "is even")

else:

print(j, "is odd")

Step-by-step explanation:

Please check the answer section.

User Kleskowy
by
5.8k points