0% found this document useful (0 votes)
14 views3 pages

Python

Uploaded by

soumyajitroy3103
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)
14 views3 pages

Python

Uploaded by

soumyajitroy3103
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/ 3

12.

Answer-

import pandas as pd

L = pd.Series([25, 22, 28.9, 27.2, 28.1, 29.9, 30.2, 31, 32.69, 32.42, 33.64, 33.8, 32,
30.6, 29.3, 28, 26.9, 26.44, 25.56, 24.398, 24.1, 23, 22.9, 22.13, 21.121, 19.7, 18.5,
17.9, 16.69,15.26])

a = L.head(7)

print("Temperatures recorded on the first 7 days:")

print(a)

b = L.tail(7)

print("Temperatures recorded on the last 7 days:")

print(b)

Output-

13. Answer -

import pandas as pd

Temp1 = pd.Series([25, 31.2, 24, 28.56, 27.23, 30.9, 24.9])

Temp2 = pd.Series([25, 22, 28.9, 27.2, 28.1, 29.9, 30.2])


Temp3 = pd.Series([31, 32.69, 32.42, 33.64, 33.8, 32, 30.6])

Temp4 = pd.Series([29.3, 28, 26.9, 26.44, 25.56, 24.398, 24.1])

w= sum(Temp1)/len(Temp1)

x= sum(Temp2)/len(Temp2)

y= sum(Temp3)/len(Temp3)

z= sum(Temp4)/len(Temp4)

print("Week 1 : Average Temperature is", w, "degree Celsius")

print("Week 2 : Average Temperature is", x, "degree Celsius")

print("Week 3 : Average Temperature is", y, "degree Celsius")

print("Week 4 : Average Temperature is", z, "degree Celsius")

total = w+x+y+z

print("Average temperature of entire month:", total / 4, "degree Celsius")

Output-

14. Answer -

import pandas as pd

d = [{'old price': 12, 'new price': 16, 'change': 4}, {'old price': 18, 'new price': 13,

'change': -5}, {'old price': 21, 'new price': 33, 'change': 12}]

df = pd.DataFrame(d)

print(df)

Output -
36. Answer -

import pandas as pd

data = {'Item': ['Pen', 'Pencil', 'Notebook'], 'Sales': [180, 150, 75]}

df = pd.DataFrame(data)

df.to_csv('x.csv', index = False)

p = pd.read_csv('x.csv', sep = '@')

print(p)

Output -

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy