Question: 4.2 Problem 1 (1 mark) Problem: Writeprogram that reads whole numbers typed by the user until a negative number is entered, then prints the number

4.2 Problem 1 (1 mark)

Problem: Writeprogram that reads whole numbers typed by the user until a negative number is entered, then prints the number of even numbers that were entered.Sample run:

$python3 CountEvens.py

Enter a number: 3

$Enter a number: 4

$Enter a number: 7

$Enter a number: 2

$Enter a number: 2

$Enter a number: 9

$Enter a number: -1

3 even numbers were entered.

$

Hint: Use the sentinel pattern.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!