Is there a way to make this code more “Neat”?

Refresh

February 2019

Views

11 time

0

The user inserts multiple values and the program determines how many positive values, negative values, zero values, even values, odd values, and the min, max, average, and total of those values. The code works, however it's quite messy.

negative=0
zero=0
positive=0
even=0
odd=0
max=0
min=0
a=int(input('Number of values:'))
b=int(input('First value:'))
if b==0:
    zero=1
if b<0:
    negative=1
if b>0:
    positive=1
if b%2==0:
    even=1
else:
    odd=1
if b>max:
        max=b
total=b
for x in range(a-1):
    b=int(input('Next value:'))
    total+=b
    if b==0:
        zero+=1
    if b==0:
          zero+=1
    if b<0:
          negative+=1
    if b>0:
          positive+=1
    if b%2==0:
          even+=1
    else:
         odd+=1
    if b>max:
        max=b
    if b<=min<=b and b<max:
        min=b
print('Negative values:',negative)
print('Zero values:',zero)
print('Positive values:',positive)
print('Even values:',even)
print('Odd values:',odd)
print('Total:',total)
print('Minimum:',min)
print('Maximum:',max)
print('Average:',total/a)

0 answers