Ai Practical
Ai Practical
12. Create a pandas DataFrame with one column and display it.
14. Write a program to calculate the sum of all values in a pandas DataFrame column.
print("Hello, World!")
Output:
Hello, World!
print("Sum:", a + b)
Input:
Output:
Sum: 8
print("Square:", num ** 2)
Input:
Enter a number: 4
Output:
Square: 16
4. Take input from the user and display it
Input:
Output:
if num % 2 == 0:
print("Even")
else:
print("Odd")
Input:
Enter a number: 7
Output:
Odd
print("List:", numbers)
Output:
numbers = [1, 2, 3, 4, 5]
print("Sum:", sum(numbers))
Output:
Sum: 15
8. Reverse a string
Input:
Output:
if num % 5 == 0:
print("Divisible by 5")
else:
Input:
Enter a number: 25
Output:
Divisible by 5
10. Calculate the area of a rectangle
Input:
Output:
Area: 15.0
import numpy as np
Output:
NumPy Array: [1 2 3]
import pandas as pd
print(data)
Output:
Numbers
0 10
1 20
2 30
13. Add two NumPy arrays element-wise
import numpy as np
Output:
Sum of arrays: [5 7 9]
import pandas as pd
Output:
Sum of column: 60
import numpy as np
Output:
Maximum value: 40