Question: 1. [4 pts] Write a Python program to: a) Request the user to enter a positive integer; b) Starting from 2, print all positive even

1. [4 pts] Write a Python program to:

a) Request the user to enter a positive integer;

b) Starting from 2, print all positive even numbers that are strictly less than (<) the user input

c) Print numbers in one line but separate them in some way (you decide)

2. [3/4 pts] Write 2 separate Python programs (2A & 2B) to perform the following tasks.

Part A.

a) Request the user to enter a positive integer;

b) Among positive integers that are strictly less than the user input, print & count those divisible by

3 (multiples of 3, i.e., 3, 6, 9, ...)

Part B.

a) Request the user to enter a positive integer;

b) Starting from 1, print all integers that are divisible by 3 or 5 in the ascending order;

c) Stop printing when the number of printed numbers equals the user input in a);

d) Calculate and print the average of all printed numbers.

3. [4 pts] Write a Python program to:

a) Continuously request the user to enter positive numbers, one at a time

b) When the user enters a 0, stop requesting for inputs

c) When the user enters a negative number, exclude it from calculation (instructions provided in d)

and print: "Negative numbers are invalid! Please re-enter."

d) Calculate and print the average of all valid inputs (excluding zero and negative ones).

Hint 1: Use an infinite loop to request for inputs continuously. Use break and if statement together to

terminate that loop when a 0 is input.

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!