You are on page 1of 6

BAGTING, MARVIN D.

CPE 401 – COMPROG


ME-1203 ACTIVITY 2.1

1. Write a Python program to check whether a number is divisible by 5 and 11 or not


using if else. How to check divisibility of any number in Python programming.
Python program to enter any number and check whether it is divisible by 5 and 11
or not. Logic to check divisibility of a number in a Python program.

Sample Output 1:
Let us check if your number is divisible by 5 and 11:
----------------------------------------------------------------
Input a number: 55
Output
Number is divisible by 5 and 11.

Sample Output 2:
Let us check if your number is divisible by 5 and 11:
----------------------------------------------------------------
Input a number: 44
Output
Number is not divisible by 5 and 11.

PROGRAM CODE

#Bagting, Marvin D.
#ME-1203
#Actual Activity 2.1

x = int(input("Let us check if your number is divisible by 5 and 11: "))

print("-----------------------------------------------------------")

if ((x % 5 == 0) and (x % 11 == 0)):


print ("Number is divisible by 5 and 11.")
else:
print ("Number is not divisible by 5 and 11.")
SS OF PROGRAM
2. Write a program that determines a student's final grade. The program will read
three types of score(exercise, mid-term and final score) and determine the grade
based on the following rules. Use nested if statement or if-elif-else statement.

- if the average score is greater or equal to 90% then final grade=A


- if the average score greater than or equal to70% and less than 90% then final
grade=B
- if the average score greater than or equal to 50% and less than 70% then
final grade=C
- if the average score less than 50% then final grade=F

Sample Output 1:
Let us check your Final Grade:
-----------------------------------------
Enter your exercise score: 90
Enter your midterm score: 90
Enter your final score: 93
Your final average is: 91%

Remarks:
Final Grade is: A

Sample Output 2:
Let us check your Final Grade:
-----------------------------------------
Enter your exercise score: 75
Enter your midterm score: 78
Enter your final score: 89
Your final average is: 80.67%

Remarks:
Final Grade is: B

Sample Output 3:
Let us check your Final Grade:
-----------------------------------------
Enter your exercise score: 65
Enter your midterm score: 68
Enter your final score: 70
Your final average is: 67.67%

Remarks:
Final Grade is: C
Sample Output 4:
Let us check your Final Grade:
-----------------------------------------
Enter your exercise score:48
Enter your midterm score: 47
Enter your final score: 46
Your final average is : 47%

Remarks:
Final Grade is: F

PROGRAM CODE

#Bagting, Marvin D.
#ME-1203
#Actual Activity 2.1

print("Let us check your Final Grade:")


print("---------------------------------------")

a = float(input("Enter your exercise score: "))


b = float(input("Enter your midterms score: "))
c = float(input("Enter your final score: "))

sum = a + b + c
ave = sum/3

print ("Your final average is: ", round(ave, 2) ,"%")


print()

print ("Remarks:")
if 90 <= ave:
print("Final Grade: A")
elif 70 <= ave < 90:
print("Final Grade: B")
elif 50 <= ave < 70:
print("Final Grade: C")
else:
print("Final Grade: F")
SS OF PROGRAM

You might also like