python code 1-5 class X
python code 1-5 class X
Code Output
n = int(input("Enter a Number:"))
if n == 1:
print(n, "is not a prime number.")
elif n>1:
for i in range(2, n):
if (n % i) == 0:
print(n, "is not a prime number.")
break
else:
print(n, "is a prime number.")
Date :
Practical 2: Program to input two numbers and find their HCF and LCM.
Code Output
a = int(input("Enter the first value:"))
b = int(input("Enter the second
value:"))
HCF=1
for i in range (2, a+1):
if(a % i == 0 and b % i == 0):
HCF = i
LCM = int((a * b)/(HCF))
print("LCM of the numbers is:", LCM)
print("HCF of the numbers is :", HCF)
Date :
Practical 3: Program to define a userdefined list of 10 integers and print only even
numbers form the list.
Code Output
a = []
print("Please enter 10 integers:")
for i in range(10):
x = int(input(f"Enter integer {i+1}: "))
a.append(x)
print("Even numbers from the list
are:")
for i in range(10):
if a[i] % 2 == 0:
print(a[i])
Date :
Practical 4: Program to create a list of students marks with user- defined values and
find the maximum.
Code Output
a = []
n = int(input("Enter the total number of
subjects: "))
for i in range(n):
x = int(input(f"Enter the marks for
subject {i+1}: "))
a.append(x)
print("The highest marks are", max(a))
Date :
Practical 5: Program to add the user defined elements of two lists.
Code Output
list1 = []
list2 = []