- # -*- coding: utf-8 -*-
- """
- Spyder Editor
- @author: fradim
- """
- '''
- Given an integer n, n>0, and a sequence with n
- whole numbers, determine how many numbers in the
- sequence are even and how many are odd.
- For example, for the sequence
- 6 -2 7 0 -5 8 4
- your program should write the number 4 to the
- number of evens and 2 for the number of odds.
- '''
- #1 read the string size
- n = int(input("Enter n: "))
- #2 initialize counters
- count_pair = 0
- odd_count = 0
- # 3 read sequence and determine on evens and odds
- i = 0
- while i < n:
- num = int(input("Enter a number: "))
- remainder = num %2
- if remainder == 0:
- count_par = count_par + 1
- else: # else
- odd_count = odd_count + 1
- i = i + 1
- #4 write the answer
- print(f"{count_pair} pairs")
- print(f"{odd_count} odd")
Raw Paste