If ,else and elif condition statements
If ,else and elif condition statements
First Program:
OutPut:
Enter the principle amount=2000
Enter the value of year=1
Therefore simple interest is given as=0.4
Second Program:
Output:
ERROR!
File "<string>", line 22
print("Accumulated amount is =" + str(A))
IndentationError: unexpected indent
Output:
If p=20000
Enter the value of principle=20000
Enter the value of Year1
Hence compound interest is = Rs.40000.0
Accumulated amount is =60000.0
Or if p=9000
Enter the value of principle=9000
Enter the value of Yaer1
Hence compound interest is = Rs.13500.0
Accumulated amount is =22500.0
Question set
1. If his basic salary is less than Rs. 1500, then HRA=10% of basic salary and DA =90% of
basic salary. If his salary is either equal to or above Rs.1500, then HRA= Rs. 500 and
DA =98% of basic salary. If the employee’s salary is input through the keyboard, write a
program to find his gross salary.
2. While purchasing certain items, a discount of 10% is offered if the quantity purchased is
more than 1000. If quantity and price per item are input through the keyboard, write a
program to calculate the total expenses.
3. Percentage marks obtained by a student are input through the keyboard. The student
gets a division as per the following rules:
● Percentage above or equal to 60 - First division
● Percentage between 50 and 59 - Second division
● Percentage between 40 and 49 - Third division
● Percentage less than 40 - Fail
Write a program to calculate the division obtained by the students.
4. A company insures its drivers in the following cases:
● If the driver is married.
● If the driver is unmarried, male & above 30 years of age.
● If the driver is unmarried, female & above 25 years of age.
In all other cases, the driver is not insured. If the marital status, sex and age of the
driver are the inputs, write a program to determine whether the driver should be insured
or not.
5. Write conditional expression for
● If a<10 b=20, else b=30
● Print ‘morning ‘ if time < 12, otherwise print ‘Afternoon’
● If marks >=70, set remarks to true, otherwise False
6. Rewrite the following code snippet in 1 line:
x=3
y = 3.0
If x==y:
print(“x and y are equal’)
else:
print(“a and y are not equal”)
7. Write the output of the following program
1) a=10
If a =30 or 40 or 60:
print(“Hello”)
else:
print(“Hi“)