Professional Documents
Culture Documents
LIST OF PROGRAMS
SOURCE CODE:
Test Input:
Enter a number: 5
Expected Output:
The factorial of 5 is 120
SOURCE CODE:
n = int(input("Enter the value of n : "))
f1 = 0
f2 = 1
sum = 0
count = 1
print("Fibonacci Series: ", end = " ")
while count <= n:
print(sum, end = " ")
count += 1
f1 = f2
f2 = sum
sum = f1 + f2
OUTPUT :
Enter the value of n : 10
Fibonacci Series: 0 1 1 2 3 5 8 13 21 34
3. Write a program to print the multiplication table from (1-10) in
python.
Source code :
print("Multiplication")
n=int(input("Enter the value of n : "))
for j in range(1,11):
print(n,'X',j," ",n*j)
Test Input:
Multiplication
Enter the value of n : 7
Expected Output:
7X1 7
7 X 2 14
7 X 3 21
7 X 4 28
7 X 5 35
7 X 6 42
7 X 7 49
7 X 8 56
7 X 9 63
7 X 10 70
Source code:
Test Input:
Sum of n Natural numbers
Enter the value of n : 10
Expected Output:
1
3
6
10
15
21
28
36
45
55
Source Code :
print("Area & Perimeter of circle")
print("1. Area 2. Perimeter")
ch=int(input("Enter your choice : "))
r=float(input("Enter your radius : "))
if ch==1:
a=3.14*r*r
print("Area of circle is : ",a)
elif ch==2:
p=2*3.14*r
print("Perimeter of circle is : ",p)
else:
print("Enter one or two")
Test Input:
Test Input:
Enter First Number=60
Enter Second Number=48
Enter Third Number=50
Expected Output:
The greatest number is = 60
Expected Output:
RESULT:
Thus, the given program has been executed and verified successfully
OUTPUT:
*
* *
* * *
* * * *
* * * * *
PROGRAM:
line=input(‘Enter a String : ‘)
st=''
n=len(str)
for k in range(n-1,-1,-1):
st=st+str[k] #copy from last
print('Reversed String : ',st)
if str==st:
print(str,'is a Palindrome')
else:
print(str,'Not a Palindrome')
Test Input:
Enter a String : malayalam
Reversed String : malayalam
Expected output:
malayalam is a Palindrome