Anjeev Singh Academy

Anjeev Singh Academy

Class 12 IP 065 Ch 1 Python Pandas 1 Type C Long Answer Questions

Chapter 1 : Python Pandas – I

Sumita Arora Book Exercise Solution of Class 12 Informatics Practices [065]

Type C – Long Answer Questions

Programming Skills


1. Write Python code to create a Series object Temp1 that stores temperatures of seven days in it. Take any random seven temperatures.

Ans:

import pandas as pd

import numpy as np

tempArr = np.random.randint(10,30,7)

temp1 = pd.Series(tempArr)

print(“Seven Days Temperaturs are “)

print(temp1)


2. Write Python code to create a Series object Temp2 storing temperatures of seven days of week. Its indexes should be ‘Sunday’, ‘Monday’,… ‘Saturday’.

Ans:

import pandas as pd

import numpy as np

days = [‘Sunday’, ‘Monday’, ‘Tuesday’, ‘Wednesday’, ‘Thursday’, ‘Friday’, ‘Saturday’]

tempArr = np.random.randint(10,30,7)

temp1 = pd.Series(tempArr, index=days)

print(“Seven Days Temperaturs are “)

print(temp1)


3. A series object (say T1) stores the average temperature recorded on each day of a month. Write code to display the temperatures recorded on: (i) first 7 days (ii) last 7 days.

Ans:

import pandas as pd

import numpy as np

avgTemp = np.random.randint(15,30, 30)

T1 = pd.Series(avgTemp, index=range(1,31))

print(“First 7 Days tempertures “)

print(T1.head(7))

print(“Last 7 Days temperaturs “)

print(T1.tail(7))


Sorry! You cannot copy content of this page. Please contact, in case you want this content.

Scroll to Top