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

Python Exp12

The document contains three Python code snippets utilizing the pandas library. The first snippet creates a Series to display daily calorie consumption, the second constructs a DataFrame for fruit prices and calculates total costs for 10 items, and the third generates a DataFrame of random numbers and computes their mean. Each code section is followed by its expected output.

Uploaded by

prxveshhh9636
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 views2 pages

Python Exp12

The document contains three Python code snippets utilizing the pandas library. The first snippet creates a Series to display daily calorie consumption, the second constructs a DataFrame for fruit prices and calculates total costs for 10 items, and the third generates a DataFrame of random numbers and computes their mean. Each code section is followed by its expected output.

Uploaded by

prxveshhh9636
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

1.

SOURCE CODE :-
import pandas as pd
calories = {"day1": 420, "day2": 380, "day3": 390}
calorie_series = pd.Series(calories)
print("Calories consumed each day:\n", calorie_series)

OUTPUT :

2. SOURCE CODE :-
import pandas as pd
data = {
"Product": ["Apple", "Banana", "Cherry", "Date"],
"Price (USD)": [1.2, 0.5, 3.0, 2.5]
}
df = pd.DataFrame(data)
print(df)
df["Total Cost for 10 items (USD)"] = df["Price (USD)"] * 10
print("\nUpdated DataFrame with Total Cost for 10 items:")
print(df)

OUTPUT :
3. SOURCE CODE :-
import pandas as pd
import numpy as np
random_numbers = np.random.randint(1, 100, size=10)
df = pd.DataFrame(random_numbers, columns=["Numbers"])
print("DataFrame with Random Numbers:")
print(df)
mean_value = df["Numbers"].mean()
print("\nMean of the Numbers:", mean_value)

OUTPUT :

You might also like