You are on page 1of 4

BAGTING, MARVIN D.

CPE 401 – COMPROG


ME – 1103 PRACTICAL ACTIVTY NO. 2

A.

1. Create a program that will show the 4 basic operation(addition, subtraction


division and multiplication)

Output Example:

Enter a number:25
Enter a number:25
Addition = 50
Subtraction= 0
Multiplication= 625
Division= 1.0

2. Create a program that will allow a person to vote on election, if the voter is 18
years of age or above.

Output Example:

Enter your age: 25


You are allowed to vote if the statement is true: True

3. Create a program that will compare 3 values.


-Input values
-Print result based on input

Output Example
input value of a, b,c;
(b<=c) & (b>=a)
ANSWERS:

1. PROGRAM CODE

#Bagting, Marvin D.
#ME1203
#Practical Activity 2

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


B = int(input("Enter a number: "))
print("Addition = ", A+B )
print("Subtraction = ", A-B )
print("Multiplication = ", A*B )
print("Division = ", A/B )

PROGRAM SCREENSHOT
2. PROGRAM CODE

#Bagting, Marvin D.
#ME1203
#Practical Activity 2

A = int(input("Enter your age: "))


print("You are allowed to vote if the statement is true: ", A>=18)

PROGRAM SCREENSHOT
3. PROGRAM CODE

#Bagting, Marvin D.
#ME1203
#Practical Activity 2

A = int(input("Enter your 1st number: "))


B = int(input("Enter your 2nd number: "))
C = int(input("Enter your 3rd number: "))

print((A>B) and (B<C))


print((C!=A) or (A==C))
print(not(-B<C))

PROGRAM SCREENSHOT

You might also like