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

Python Scripts for Grade and Roots Calculation

Uploaded by

RAJYALAKSHMI
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

Python Scripts for Grade and Roots Calculation

Uploaded by

RAJYALAKSHMI
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Week-2

i) Write a python script to take five subject marks and print the grade for the student.

print("Enter Marks Obtained in 5 Subjects: ")


sub1=int(input("Enter subject1 marks"))
sub2=int(input("Enter subject2 marks")) OUTPUT:
sub3=int(input("Enter subject3 marks")) Enter Marks Obtained in 5 Subjects:
sub4=int(input("Enter subject4 marks")) Enter subject1 marks65
sub5=int(input("Enter subject5 marks")) Enter subject2 marks90
Enter subject3 marks89
tot = sub1+sub2+sub3+sub4+sub5 Enter subject4 marks98
Enter subject5 marks76
print("Total Marks=", tot)
Total Marks= 418
avg = tot / 5
Average marks= 83.6
print("Average marks=",avg)
Your Grade is A2
if avg >= 91 and avg <= 100:
print("Your Grade is A1")
elif avg >= 81 and avg < 91:
print("Your Grade is A2")
elif avg >= 71 and avg < 81:
print("Your Grade is B1")
elif avg >= 61 and avg < 71:
print("Your Grade is B2")
elif avg >= 51 and avg < 61:
print("Your Grade is C1")
elif avg >= 41 and avg < 51:
print("Your Grade is C2")
elif avg >= 33 and avg < 41:
print("Your Grade is D")
elif avg >= 21 and avg < 33:
print("Your Grade is E1")
elif avg >= 0 and avg < 21:
print("Your Grade is E2")
else:
print("Invalid Input!")

ii) Write the python script to print whether the roots are equal, distinct or complex for
given coefficients a, b and c for quadratic equation.
import math
OUTPUT:
a=int(input("enter a: ")) enter a: 1
b=int(input("enter b: ")) enter b: 10
c=int(input("enter c: ")) enter c: -24
dis = b * b - 4 * a * c real and different roots
sqrt_val = [Link](abs(dis)) 2.0
if a == 0: -12.0
print("Input correct quadratic equation")

elif dis > 0:


print("real and different roots")
print((-b + sqrt_val)/(2 * a))
print((-b - sqrt_val)/(2 * a))

elif dis == 0:
print("real and same roots")
print(-b / (2 * a))

# when discriminant is less than 0


else:
print("Complex Roots")
print(- b / (2 * a), + i, sqrt_val / (2 * a))
print(- b / (2 * a), - i, sqrt_val / (2 * a))

You might also like