Python Conditional Statement Using for Average & Percentage of User Input Marks with Pass & Fail Check
Creating a Python program that calculates the average and percentage of user input marks, along with implementing a pass/fail check using if-else statements.
{Formula to calculate the Average of Marks is (Marks of Subject 1 + Marks of Subject 2+Marks of Subject 3 + Marks of Subject 4 + Marks of Subject 5)/Total No. of Subjects
Formula to Calculate the Percentage of Marks is (Total No. Subject Marks / Total Marks of Subjects) * 100 (Multiplied by 100)}
Input is Shown Below :
Code :
Output is Shown Below :
Explanation:
- Five variables a, b, c , d and e are taking user input values of each subject marks
- Now all values are stored in these 5 variables
- Now lets take average of all these 5 variables (means like addition of all 5 variables) and stored it in new variable f (And, we can take directly the all formula in single variable but according to BODMASS Rule, the python follows that so then answer might vary that's why all variables are taken separately)
- Now the lets assign a new variable t which will store the average of 5 variables i.e. (f divided by total marks of all subjects which will be simply (5*100) = 500 and then simply, multiply it by 100 to get point value.
- Now we will print the values stored inside the s variable and with a line of average of marks is
- Now we will print the values stored inside the t variable and with a line of percentage is
- After this we will execute the if conditional statement that if total percentage of all subjects is greater than or equal to 50 then print the student is pass
- Else then print directly that student is fail
- The output will show the final results after taken user input values that whether the student is pass or fail that will get decided by conditional statements.


Comments
Post a Comment