Python Programming I IPT102 University of Batangas Activity and Quiz
Python Programming I IPT102 University of Batangas Activity and Quiz
Write a Python (or R) program that asks the user to enter an integer (X), then:
if X > 1:
for i in range(2, X):
if (X % i) == 0:
print(X, "is not a prime number")
print(i, "times", X//i, "is", X)
print (factors(X))
break
else:
print(X,"is a prime number")
else:
print(X,"is not a prime number")
print (X, "'s factors are: ", factors(X))
# Evaluate and print the equation Y=8X²+ 1, for X values from -5 to 5 using the range
function and for loop
count = 1
for x in range(-5, 5, 1):
equation = 8 * x**2 +1
print("Equation ",count, " = 8+ (", x, ")^2 +1 = ", equation)
count = count +1
Sample Output