0% found this document useful (0 votes)
207 views4 pages

Series Programs

The document contains solutions to 7 programming problems involving generating series in Python. Program 1 generates a series of numbers from 1 to 10. Program 2 generates a series of float numbers from 21.0 to 30.0 with an increment of 1.5. Program 3 generates a series using a dictionary to represent month numbers and names. The remaining programs demonstrate various methods for generating series with different conditions, such as using multiples of 7 with a specified index or modifying existing series based on certain criteria.

Uploaded by

taksunilratan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
207 views4 pages

Series Programs

The document contains solutions to 7 programming problems involving generating series in Python. Program 1 generates a series of numbers from 1 to 10. Program 2 generates a series of float numbers from 21.0 to 30.0 with an increment of 1.5. Program 3 generates a series using a dictionary to represent month numbers and names. The remaining programs demonstrate various methods for generating series with different conditions, such as using multiples of 7 with a specified index or modifying existing series based on certain criteria.

Uploaded by

taksunilratan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Program 1 .

Write a program to generate a series of 10 numbers

Solution :

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

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

Solution :

import numpy as np
import pandas as pd
def serExp():
n = np.arange(21.0, 32.0, 1.5)
s = pd.Series(n)
print(s)
serExp()
Program 3 : Write a Program to generate a Series using a dictionary to represent month number and
month Name.
Sol :
import pandas as pd
def serDict():
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)
serDict()

Output:

Program 4 : Write a program to generate a series of 5 elements of multiples of 7 starting with 35 with
index multiply by 3.
Sol :
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()
Output
Program 5 :Write a program to generate a series of marks of 10 students. Give grace marks upto 5 of
those who are having <33 marks and print the new list of the marks.
Solution :
import pandas as pd
def ser_marks():
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("\nOld List is : \n",s)
print("New list is : ")
print(s[s>=33])
ser_marks()
Input Output

Program 6: Write a program to generate series of 10 numbers starting from 41 and with increment of
3 now add 4 to all odd values and subtract 3 to all even numbers. Reprint updated series.
Solution :
import pandas as pd
s = pd.Series(range(41, 71, 3))
print(s)
s[s%2 !=0]= s+4
s[s%2 == 0] = s-3
print(s)
Program 7 : Write a Program to Generate S1 with prime numbers between 1 to 25 and S2 with factorial
numbers between 1 to 25.

You might also like