back

Py Home Work

Python Practice Problems

If Else

  1. Compute Indian income tax rate for given annual salary 1 a. [4-8 -> 5%, 8-12 -> 10%, 12-16 -> 15%, 16-20 -> 20%, 20-24 -> 25%, above 24 -> 30%]
  2. Given a metal name (gold, silver, platinum), print their price
  3. Given a number, if odd double it (2x), if even return same. 3 -> 6, 4 -> 4
  4. Given two numbers find min
  5. Given two number find max
  6. Given number, print day of the week 1 -> Monday 7 -> Sunday
  7. Given exam scores ex [50, 23, 36, 45, 30] check if user failed or passed an exam. Pass score 36
  8. Given an number, print whether given number is positive, negative or zero
  9. Given room temperature, print whether it is Normal, Hot or Cold
    1. 21-24 Normal
    2. Above 24 Hot
    3. Below 21 Cold
  10. Given age check if user can vote. min age 18
  11. Given age check if user can drive min age 18
  12. Given mark check if user fail. pass mark 36
  13. Given mark check if user scored centum (100)
  14. Given body temperature check if user has fever (more than 100)
  15. Given user name, password print ‘success’ if they match ‘admin’, ‘1234’
  16. Given a number, print ‘positive’, ‘negative’ or ‘zero’
  17. Check if given number is divisible by 3 and 5
  18. Check if a candidate is eligible to appear for a role with age limit 21-32
  19. Given a day check if it falls on week end (sat/sun)
  20. Given a color name check if it is primary color (Red/Green/Blue)