You are on page 1of 5

ACTUAL

ACTIVITY 3
COMPUTER PROGRAMMING

RENMARK D. MARTINEZ
CE-1201
Direction:Create a python program using While or For

1. Accept 5 numbers from the user and display the sum of numbers divisible by 5.

Sample Output:

Enter number 1: 10
Enter number 2: 35
Enter number 3: 48
Enter number 4: 26
Enter number 5: 15

Sum of numbers divisible by 5=60

PROGRAM CODE AND OUTPUT SCREENSHOTS


PROGRAM CODE:

#RENMARK D. MARTINEZ
#CE-1201
#ACTUAL ACTIVITY 3

a=int(input("Enter number 1:"))


b=int(input("Enter number 2:"))
c=int(input("Enter number 3:"))
d=int(input("Enter number 4:"))
e=int(input("Enter number 5:"))
sum = 0
for x in [a,b,c,d,e]:
if(x%5==0):
sum=sum+x
print("Sum of numbers divisible by 5:", sum)
2. Accept even numbers and display. The program will stop when an odd
number is entered.

Sample Output 1:
Enter a number: 2
Number 2 is an even number.

Sample Output 2:
Enter a number: 3
The number you’ve entered is not an even number.

PROGRAM CODE AND OUTPUT SCREENSHOTS


PROGRAM CODE:

#RENMARK D. MARTINEZ
#CE-1201
#ACTUAL ACTIVITY 3

number=0
number= int(input("Enter number: "))
i=0
while i==0:
if (number % 2 ==0):
print ("Number", number, "is an even number.")
number = int(input("Enter number: "))
continue
else:
print ("The number you've entered is not an even number.")
break

You might also like