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

Untitled13.ipynb - Colab

The document contains several Python programs that perform basic mathematical operations, including generating a multiplication table, checking for prime numbers, finding factors, identifying perfect numbers, summing a list of numbers, and counting even or odd numbers. Each program prompts the user for input and displays the results accordingly. The document is structured as a Jupyter notebook with code snippets and example outputs.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views2 pages

Untitled13.ipynb - Colab

The document contains several Python programs that perform basic mathematical operations, including generating a multiplication table, checking for prime numbers, finding factors, identifying perfect numbers, summing a list of numbers, and counting even or odd numbers. Each program prompts the user for input and displays the results accordingly. The document is structured as a Jupyter notebook with code snippets and example outputs.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

23/01/2025, 18:09 Untitled12.

ipynb - Colab

1 wap to accept n and print its table

n=int(input("enter the value of n"))


for a in range(1,n+1):
print(n,"x",a,"=",n*a)

enter the value of n5


5 x 1 = 5
5 x 2 = 10
5 x 3 = 15
5 x 4 = 20
5 x 5 = 25

2 wap to accept the number and check if prime or not

n=int(input("enter number"))
factor=0
for a in range(1,n+1):
if n%a==0:
factor+=1
if factor==2:
print(n,"n is a prime number")
else:
print(n,"n is a composite number")

3wap to accept a number and display all its factors

n=int(input("enter value of n"))


f=0
for a in range(1,1+n):
if n%a==0:
print(a)

4wap to accept a number and check if it a perfect number factor+=a if factor==2*n:

n=int(input("enter value of n"))


factor=0
for a in range(1,n+1):
if n%a==0:
factor+=a
if factor==2*n:
print(n,"it is a perfect number")
else:
print(n,"it is not a perfect number")

enter value of n6
6 it is a perfect number

https://colab.research.google.com/drive/1fmtDGJqB4lTkt0zvD_cspR4os06tc1aX 1/2
23/01/2025, 18:09 Untitled12.ipynb - Colab

wap to accept 10 numbers and find their sum

sum=0
for a in range(10):
x=int(input("enter number"))
sum+=x
print("sum",sum)

wap to accept 10 number and count even or odd

for a in range(10):
x=int(input("enter number"))
if x%2==0:
print(x,"it is even")
else:
print(x,"it is odd")

enter number10
enter number11
enter number12
enter number13
enter number46
enter number23
enter number21
enter number34
enter number50
enter number223
223 it is odd

https://colab.research.google.com/drive/1fmtDGJqB4lTkt0zvD_cspR4os06tc1aX 2/2

You might also like