Shoeb - CLP - 03
Shoeb - CLP - 03
CLP-3
Student Details
Name ID
Ans:
Output:
Display Fibonacci series up to 10 terms
Ans:
Output:
Calculate the cube of all numbers from 1 to a given
Number
Ans:
Output:
Write a program to print the following patterns
Ans:
Output:
Ans:
Output:
Python program to interchange first and last elements in
a list
Ans:
a=[]
n= int(input("Enter the number of elements in list:"))
for x in range(0,n):
element=int(input("Enter element" + str(x+1) + ":"))
a.append(element)
temp=a[0]
a[0]=a[n-1]
a[n-1]=temp
print("interchange first and last elements:")
print(a)
Output:
Python program to find second largest number in a
list
Ans:
import array
arr = []
n = int(input("enter size of array : "))
for x in range(n):
x=int(input("enter Number : "))
arr.append(x)
sorted_array = sorted(array.array('i', arr))
for i in range(len(arr)-1, 0, -1):
if sorted_array[i]!=sorted_array[i-1]:
print(f"second largest Number is {sorted_array[i-1]}")
break
Output:
Python program to print all prime numbers in a range
Ans:
First = int(input("Enter First Number: "))
Secound = int(input("Enter Secound Number: "))
Output: