Python Programs
Python Programs
for i in range(5,0,-1):
print("* "*i)
'''
'''WAP to print sum of first 10 natural numbers
n=0
for i in range(1,11):
n=n+i
print(n)
'''
'''WAP to print odd numbers from 1 to n
t=int(input("enter the value of t"))
for i in range(1,t):
if(i%2!=0):
print(i)
'''
'''
WAP to print first 10 even numbers
for i in range(1,11):
if(i%2==0):
print(i)
'''
'''
WAP to print first 10 natural numbers
for i in range(1,11):
print(i)
'''
'''WAP to input a number and check if the number is positive, negative or Zero and
display an appropriate message
#Create a list of 10 even numbers,add 1 to each list item and print the final list.
#add 5 at index no 4 in a list.
list_1=[2,4,6,8,10,12,14,16,18,20]
print(list_1)
for index in range(len(list_1)):
list_1[index]=list_1[index]+1
print(list_1)
list_1[4]=list_1[4]+5
print(list_1)
# Create a list List_1=[10,20,30,40].Add the elements[14,15,12] using extended
function.Now sort the final list in ascending order and print it.
list_1=[10,20,30,40]
print(list_1)
list_1.extend([14,15,12])
print(list_1)
list_1.sort()
print(list_1)
import numpy
rollno=numpy.array([1,2,3])
print(rollno)
import numpy as np
p=np.arange(10,101,10)
print(p)
a=np.random.random(4)
print(a)
b=np.random.randint(5,size=(3,6))
print(b)
a=[1,2,3,4,1,1,11,1,1]
b=[4,5,6,7,8,9,5,6,5,6,5,6,5,6,8]
if (len(a)>=len(b)):
for i in range (len(b)):
a[i]=(a[i]+b[i])
print(a)
else:
for i in range (len(a)):
b[i]=(b[i]+a[i])
print(b)
# Write a program to add the elements of the two lists with different size.
a=[1,2,3,4,1,1,11,1,1]
b=[4,5,6,7,8,9,5,6,5,6,5,6,5,6,8]
if (len(a)>=len(b)):
for i in range (len(b)):
a[i]=(a[i]+b[i])
print(a)
else:
for i in range (len(a)):
b[i]=(b[i]+a[i])
print(b)
import pandas as pd
x=int(input("enter the number of rows which u you want to access"));
p=pd.read_csv("C:\\Users\\user27\\Desktop\\salary.csv",nrows=x)
print(p)
#Read csv file saved in your system and display its information.
import pandas as pd
p=pd.read_csv("C:\\Users\\user27\\Desktop\\salary.csv")
print(p)