0% found this document useful (0 votes)
3 views

python code 1-5 class X

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

python code 1-5 class X

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Date :

Practical 1: Program to check user defined number is prime or not.

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 = []

n = int(input("Enter the number of


integers to enter in each list: "))

print("Enter the integers for list1:")


for i in range(n):
x = int(input(f"Enter integer {i+1}: "))
list1.append(x)

print("Enter the integers for list2:")


for i in range(n):
x = int(input(f"Enter integer {i+1}: "))
list2.append(x)

print("The sums of corresponding


elements are:")
for i in range(n):
sum = list1[i] + list2[i]
print(sum)

You might also like