Python Programming Lab
Python Programming Lab
No : 1
Date :
Area and Perimeter of a Circle.
Aim :
To calculate the area and perimeter of a circle
Algorithm :
Program :
radius = int(input("Enter radius value : "))
Area =0
Perimeter =0
Area = π * radius * radius
Perimeter = 2 *π * radius
print("Area is", Area)
print(“Perimeter is", Perimeter)
Output :
Enter radius value : 2
Area is 12.56
Perimeter is 12.56
Result :
The area and perimeter of a circle is calculated for the given the radius.
Ex.No : 2
Date :
FIBONACCI SERIES
Aim :
To generate the Fibonacci Series for n terms using Python
Algorithm :
Step 1 → Input N
Step 2 → Set A = 0, B = 1
Step 3 → Display A, B
Step 4 → C = A + B
Step 5 → Display C
Step 6 → Set A = B, B = C
Step 7 → Repeat steps 4 to 6 for n times
Program :
num1 = int(input("Enter n value : "))
a=0
b=1
print("Fibonacci Series ..... ")
print("0 1",end=" ")
i=2
while(i <= num1-1):
c=a+b
a=b
b=c
print(c,end=" ")
i=i+1
Output :
Enter n value : 10
Fibonacci Series .....
0 1 1 2 3 5 8 13 21 34
Result :
The Fibonacci Series was generated for the given n terms.
Ex.No : 3
Date :
GCD of TWO NUMBERS
Aim :
To compute the GCD of two numbers using While loop
Algorithm :
Output
Enter a positive integer : 6
Enter a natural number : 4
Enter a natural number : 8
Enter a natural number : 6
Enter a natural number : 7
Enter a natural number : 11
Enter a natural number : 15
The sum value is 511.0
3. Find the sum of elements in an array
output
>>> Enter a String to check : racecar
The string ' racecar ' is palindrome
Output
Ragu
Abdhul
Chrisopher
7. a) List operations without using built-in functions
for i in range(n-1,-1,-1):
mL1.append(mL[i])
return mL1
Output
How many elements in a list? 3
Enter list element : 12
Enter list element : 24
Enter list element : 36
The List elements are :
12 24 36
The length of the List is : 3
The reverse of the List is : [36, 24, 12]
The copy of the List is : [12, 24, 36]
The List after clear is : []
Output