IP practical file python programs on series with solution 2021

This article provides you the IP practical file python programs on series. This is chapter 1 of IP (Informatics Practices- Class XII) chapter 1 Data handling using pandas – I as per CBSE Curriculum. This chapter is named as Python Pandas – I in Sumita Arora’s new Textbook. Here is the list and solutions in pdf.

IP practical file python programs

1 Write a program to generate a series of the first 10 numbers.

import pandas as pd
def Ser_1to10():
     s = pd.Series(range(1,11))
     print(s)
Ser_1to10()

2 Write a program to generate a series of float numbers from 21.0 to 30.0 with an increment of 1.5 each.

import pandas as pd
import numpy as np
def fl_ser():
    n = np.arange(21,32,1.5)
    s = pd.Series(n)
    print(s)
fl_ser()

3 Write a program to generate a series using a dictionary to represent month number and month names.

import pandas as pd
def Ser_dic():
    di = {1:'January',2:'February',3:'March',4:'April',5:'May',6:'June',
          7:'July',8:'August',9:'September',10:'October',11:'November',12:'December'}
    s = pd.Series(di)
    print(s)
Ser_dic()

4 Write a program to generate a series of 5 elements of multiples of 7 starting with 35 with index multiply by 3. 

import pandas as pd
import numpy as np
def Ser_mul7():
    a = 35
    n = np.arange(a,a*2,7)
    s = pd.Series(index=n*3,data=n)
    print(s)
Ser_mul7()

5 Write a program to generate a series of marks of 10 students. Give grace marks up to 5 of those who are having <33 marks and print the new list of the marks.

import pandas as pd
def Ser_stumarks():
    std_marks = []
    for i in range(1,11):
        m = int(input("Enter the marks:"))
        std_marks.append(m)
    s = pd.Series(index=range(1201,1211),data=std_marks)
    s[s<33]=s+5
    print("New List is:")
    print(s[s>=33])
Ser_stumarks()

Watch this video for more explanation about IP practical file python programs

6 Write a program to generate a series of these numbers: 33,55,65,29,19,23. Find the sum of those values which ends with 3 or 5.

import pandas as pd
list = [33,55,65,29,19,23]
ser = pd.Series(list)
val_sum = 0
sum5 = sum(ser[ser % 10 == 5])
sum3 = sum(ser[ser % 10 == 3])
print(sum3+sum5)

7 Write a program to generate a series of 10 numbers. Change the value of all the elements to 21 those values are multiples of 4.

import pandas as pd
numbers = []
# Generating a series
for i in range(1,11):
    val = int(input("Enter a number :"))
    numbers.append(val)
    ser = pd.Series(numbers)
    # Changing the values of multiple of four and assigning them a value 21
ser[ser % 4 == 0] = 21
print(ser)

8 Write a program to generate a series of 10 numbers starting with 41 and with the increment of 3. Now add 7 all odd values and reprint the updated series.

import pandas as pd
s = pd.Series(range(41,71,3))
print(s)
s[s % 2 != 0] = s + 7
print(s)

9 Write a program to generate a series of 10 numbers with scalar value 33.

import pandas as pd 
print(pd.Series(33,range(1,11)))

10 Write a program to generate series S1 with prime numbers between 1 to 25 and S2 with factorial numbers between 1 to 25. 

import pandas as pd
import math
s1 = pd.Series(x for x in range(1,25)
               if all(x % y != 0 for y in range(2, x)))
s2 = pd.Series([math.factorial(n)
                for n in range(25)])
print("Prime Number series:")
print(s1)
print("Factorial series:")
print(s2)

11 Write a program to swap the values of series to modify the contents of the series that the values which are multiples of 5 with the value present at the position in the array.

Do yourself

12 Write a program to demonstrate the use of common series attributes. Generate any series of your choice.

Do yourself by using common attributes like index, size, shape etc.

13 Write a program to generate a series and print the top 3 elements using the head function.

import pandas as pd
# generating the series
ser_length = int(input("Enter the length of the series: "))
data = []
for i in range(ser_length):
    val = int(input("Enter a val:"))
    data.append(val)
    ser = pd.Series(data)
print(ser.head(3))

14 Write a program to generate a series and print the bottom 3 elements using the tail function.

Do yourself using tail() function.

I hope you enjoyed this article forIP practical file python programs.

Access all contents of Informatics Practices

You can use this ip practical file python programs for you practical records for board examination.

I am thankful to my student Neel Patel as contributor for this article IP practical file python programs.

Dear Students, few programs I left for you. Just provide the solution in the comment section and share your views also. Share this program list with your friends as well. Thank you for visiting our blog.

Leave a Reply