https://www.rakeshmgs.in/search/label/Template
https://www.rakeshmgs.in
RakeshMgs

IF Statement and IF-ELIF Statement Python Question and Answer

Updated:

SELECTION STATEMENT

IF STATEMENT

 

Q1. Write a program to input a year in 4-digit form and check whether it is a leap year or not and display proper message.

Hint: A leap year is exactly divisible by 4 except for century years (years ending with 00). The century year is a leap year only if it is perfectly divisible by 400.

Q2. Write a program to input a character and swap it's case(i.e. If it is lowercase letter, convert it to uppercase and vice versa).

Q3. Write a program to input a number, check whether it is positive or negative and display the appropriate message.

Q4. Write a program to input cost price and selling price of an item and calculate profit and loss on a transaction.

Q5. Write a program to input a number and check whether it is even or odd and display the appropriate message.

Q6. Write a program to input two numbers and check whether both are divisible by 5.

Q7. Write a program to input a number and check whether it is divisible by 8 or not. (If the last three digits of a whole number are divisible by 8, then the entire number is divisible by 8.)

Q8. Write a program to read the age of a candidate and determine whether it is eligible for casting his/her own vote.

Q9. Write a program to input a character and display whether it is a vowel or a consonant.

   

IF-ELIF STATEMENT

Q10. Write a program to input co-efficients of a, b and c of a quadratic equation ax2 + bx + c = 0, where a = 0. Discriminant, D = b2- 4ac.If discriminant is 0 then print there is exactly one real root, if discriminant is positive then print there are two distinct roots, if discriminant is negative then print there are no real roots.

Q11. Write a program to input three sides of a triangle and display whether it is EQUILATERAL, SCALENE, RIGHT ANGLED or ISOSCELES.

Q12. Write a program to accept a date(dd/mm/yyyy) and check for its validity.

Q13. Write a program to input temperature of water and display its state (Liquid, solid or gas).

Q14. Write a program to input a character and check whether a character is an alphabet, digit or special character.

Q15. Write a program to accept a coordinate point in a XY coordinate system and determine in which quadrant(Ist, IInd, IIrd or IVth) the coordinate point lies.

Q16. Write a program to read any day number in integer and display day name in the word.

Q17. Write a program to input salary and calculate commission for the salesman. The commission is calculated as follows:

Salary                 Comission

30001 onwards           15%

22001 - 30000            10%

12001 – 22000            7%

5001 – 12000              3%

0 - 5000                      0%

Q18. Write a program to input the name, subject, salary and experience (in years) of a teacher. An allowance is given according to the following condition:

If salary >10,000 or experience > 10 years, allowance is 20% of salary.

If salary is in the range 5000-10000 and experience >5years, allowance is 15% of salary.

If salary >3000, allowance is 10%.

Otherwise if salary <3000, allowance is 6%.

Find the total salary (salary+allowance) and print it along with other details.

Q19. Write a program to calculate and print the Electricity bill of a given customer. The customer id., name and unit consumed by the user should be taken from the keyboard and display the total amount to pay to the customer. The charge are as follow:

Unit

Charge/unit

upto 199

Free

200 and above but less than 400

@1.20

400 and above but less than 600

@1.60

600 and above

@2.00

If bill exceeds Rs. 400 then a surcharge of 15% will be charged and the minimum bill should be of Rs. 150/-

 


आपको आर्टिकल कैसा लगा? अपनी राय अवश्य दें
Please don't Add spam links,
if you want backlinks from my blog contact me on rakeshmgs.in@gmail.com