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

Experiment No: 13 Date: 28/1/2022

The document contains 18 experiments from 28/1/2022 detailing python programs to solve various problems. Each experiment includes the aim, software used, program code, and result. The programs solve problems such as determining if a number is odd or even, finding the largest of three numbers, solving quadratic equations, printing the first n odd numbers, checking for palindromes, calculating factorials, and generating the Fibonacci series. All programs executed successfully and produced output as intended.

Uploaded by

Subi
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)
117 views

Experiment No: 13 Date: 28/1/2022

The document contains 18 experiments from 28/1/2022 detailing python programs to solve various problems. Each experiment includes the aim, software used, program code, and result. The programs solve problems such as determining if a number is odd or even, finding the largest of three numbers, solving quadratic equations, printing the first n odd numbers, checking for palindromes, calculating factorials, and generating the Fibonacci series. All programs executed successfully and produced output as intended.

Uploaded by

Subi
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/ 7

Experiment No: 13 Date: 28/1/2022

Odd or Even

Aim: Write a python program to find the given number is odd or even.

Software: Ubuntu (OS), python s/w and Gedit.

Program:

n=input(“Enter the number”)


print “The number is ”,n
if((n%2)==0):
print “The number is even”
else
print “The number is odd”

Result: Program is executed successfully and output is obtained.


Experiment No: 14 Date: 28/1/2022

Largest of three numbers

Aim: Write a python program to find the largest of three numbers.

Software: Ubuntu (OS), python s/w and Gedit.

Program:

a=input(“Enter 1st number”)


b= input(“Enter 2nd number”)
c= input(“Enter 3rd number”)
if(a>b) and (a>c):
large=a

elif(b>a) and (b>c):


large=b
else:
large=c
print “The largest number is”,large

Result: Program is executed successfully and output is obtained.


Experiment No: 14 Date: 28/1/2022

Quadratic Equation ax2+bx+c

Aim: Write a python program to find quadratic Equation ax2+bx+c.

Software: Ubuntu (OS), python s/w and Gedit.

Program:

import math
a = input(“ Enter the value of a “)
b = input(“ Enter the value of b “)
c = input(“ Enter the value of c ”)
d=b*b - 4*a*c
if a==0 :
print “Program is Terminating”
elif d>0 :
r1 = (-b + sqrt(d) )/(2*a)
r2 = (-b - sqrt(d) )/(2*a)
print “Roots are “ , r1 , r2
elif d==0 :
r= - b / (2*a)
print “root = “, r
else :
print “Imaginary Roots”

Result: Program is executed successfully and output is obtained.


Experiment No: 15 Date: 28/1/2022

Print first n odd numbers

Aim: Write a python program to print first n odd numbers.

Software: Ubuntu (OS), python s/w and Gedit.

Program:

n = input(“enter the no of terms ”)


x=1 ; c=1
while c<=n :
print x
x=x+2
c=c+1

Result: Program is executed successfully and output is obtained.


Experiment No: 16 Date: 28/1/2022

Palindrome checking

Aim: Write a python program to palindrome checking


.
Software: Ubuntu (OS), python s/w and Gedit.

Program:

n=input(“Enter the Number: “)


rev=0; temp=n
while temp != 0:
rev = rev * 10 + n % 10
n=n/10
if rev == n:
print n, ” is palindrome”
else:
print n, “ is not palindrome”

Result: Program is executed successfully and output is obtained.


Experiment No: 17 Date: 28/1/2022

Factorial of a number

Aim: Write a python program to find factorial of a number.


.
Software: Ubuntu (OS), python s/w and Gedit.

Program:

n=input(“Enter the Number: “)


n = input(“Enter the number ”)
x=1; fact=1
while x<=n :
fact = fact * x
x=x+1
print “Factorial of “ , n , “=”, fact

Result: Program is executed successfully and output is obtained.


Experiment No: 18 Date: 28/1/2022

Fibonacci series

Aim: Write a python program to find Fibonacci series.


.
Software: Ubuntu (OS), python s/w and Gedit.

Program:

n=input(“Enter the no of terms ”)


f1=0 ; f2=1 ; c=3
print f1 , f2
while c<=n:
f3=f1+f2
print f3
f1=f2
f2=f3
c=c+1

Result: Program is executed successfully and output is obtained.

You might also like