0% found this document useful (0 votes)
56 views2 pages

ICT Lab Assignment: ODD and EVEN Numbers Check Program

This document contains code for 3 programs: 1) A program that checks even and odd numbers within a given range and prints them separately. 2) A program that calculates the sum of even and odd numbers within a given range. 3) A program that checks if a given number is prime or not. It does this by dividing the number by all integers between 2 and the number to check for any remainders of 0.

Uploaded by

FahadKhattak
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)
56 views2 pages

ICT Lab Assignment: ODD and EVEN Numbers Check Program

This document contains code for 3 programs: 1) A program that checks even and odd numbers within a given range and prints them separately. 2) A program that calculates the sum of even and odd numbers within a given range. 3) A program that checks if a given number is prime or not. It does this by dividing the number by all integers between 2 and the number to check for any remainders of 0.

Uploaded by

FahadKhattak
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/ 2

ICT Lab Assignment

ODD and EVEN numbers check program

1. a=0
2. b=int(input("enter the range = "))
3. print("even numbers are")
4. for i in range(a,b+1,1):
5. if i % 2 == 0:
6. print(i)
7. print("odd numbers are")
8. for j in range(a,b+1,1):
9. if j % 2 == 1:
10. print(j)

Sum of EVEN & ODD numbers check

1. suma=0
2. sumb=0
3. x=int(input("enter range = "))
4. for i in range (1,x+1,1):
5. if i % 2 == 0:
6. suma=suma+i
7. else:
8. sumb=sumb+i
9. print("sum of even numbers =",suma)
10. print("sum of odd numbers =",sumb)
PRIME number check program

1. i=int(input("enter number: "))


2. if i>1:
3. for x in range(2,i):
4. if i % x == 0:
5. print(i,"is not a prime a number")
6. break
7. else:
8. print(i,"is a prime number")
9. Else:
10. print("not a prime number")

You might also like