#Program to calculate Roots of a Quadratic Equation
import math
a=int(input("enter coefficient of x**2"))
b=int(input("enter coefficient of x"))
c=int(input("enter constant"))
d=b**2-4*a*c
p=-b/2*a+math.sqrt(d)/2*a
q=-b/2*a-math.sqrt(d)/2*a
print("roots of the quadratic equation are", p,q)
Solved Programs
#Program to input salary and display corresponding grade of employee
Salary=int(input("Enter Salary of Employee"))
if Salary>25000:
print("Grade I")
elif Salary>15000:
print("Grade II")
elif Salary>9000:
print("Grade III")
else:
print("Grade IV")
#Program to input a number and check whether it is positive or negative
n=int(input("enter a number"))
if n>0 :
print("Positive")
else:
print("Negative")
-
WAP to input marks of a student, if marks are more than equal to 40 print pass else print fail.
-
WAP to input the salary of an employee, if salary is more than 60000 print “Grade I” otherwise print “Grade II”
-
WAP to input a number and check if it is even or odd.
-
WAP to input principal and time . If principal is less than 60000 set rate of interest as 9% otherwise set it at 11%. Calculate SI and amount.
Solution
5. WAP to print the Income, Tax & Surcharge of Employee.
The Tax and Surcharge are based on the following conditions
Income Tax % Surcharge
< Rs. 15000 15% 7%
Rs. 15001 to Rs. 25000 18% 11%
Above Rs. 25000 20% 13%
Calculations:
i.Total Income =Income- (Tax+Surcharge)
ii. Tax=Income*Tax_percentage/100
6. WAP to input average marks of a student and print the Division as follows:
Per Division
< 40 Failed
40 to 50 Third
50 to 60 Second
>=60 First
7. WAP to input distance to be travelled and print fare for the passenger according to the distance.
DISTANCE FARE (in Rs.)
Upto 20km 10 P/K
Next 20km 7 P/K
Above 6 P/K
8. WAP to input the number of days a member of a sports club has attended and accordingly calculate the charges. Charges are calculated as follows:
First five days : 80 rs per day.
Six to ten day : 45 rs per day.
Above ten days : 20 rs per day
9. WAP to calculate the Electricity Bill of a consumer according to the following criteria :
First 100 Units : Free.
Next 200 Units : 2 Rs per Unit
Next 350 Units 4 Rs per Unit
The consumer will input the units consumed.
10. Write a Python program to convert temperatures from Celsius to Fahrenheit or vice versa depending on user choice.
[ Formula :
C=(F-32)*5/9
F=(9/5*C) +32
[ where c = temperature in Celsius and f = temperature in Fahrenheit ]