Problem 3: Add a Grade Column
Easypython
Problem Description
Write a Python program that creates a DataFrame with a "marks" column, and adds a new "grade" column that shows "Pass" if marks are 40 or above, and "Fail" otherwise.
Input
A DataFrame with a "marks" column.
Output
The DataFrame with the additional "grade" column.
Constraints
- Marks range from 0 to 100.
Example Input
text{"marks": [55, 30, 80]}
Example Output
textmarks grade 0 55 Pass 1 30 Fail 2 80 Pass
Concepts Covered
Adding columns, conditional logic on columns, apply() or vectorized conditions.