# Java, .NET, PHP, PYTHON, ANGULAR, ML, Data Science, Testing, CI Tutorials in Easy Languages.

## 1) Simple if:-

It will be executed when the condition will be true. for example,

if we want to display the salary of employees when the salary will be above 10000 otherwise not display.

Syntax:-

## statements

### Q) WAP to increase the salary of employees from 500 if entered salary will be less than 10000 otherwise the same salaries will be displayed.

Solution:-

x = int(input("enter salary"))
if x<10000:
x=x+500
print(x)

Q) WAP to display the subject mark of the student which will be entered by the user's if the entered subject mark is eligible for grace then display mark including grace mark otherwise actual mark will display.

x = int(input("enter mark"))
if x>=28 and x<33:
g=33-x
print('grace mark is ',g)
x=x+g

print(x)

## 2) If...Else:-

'Else' is the dependent statement of if statement.
If--else will be implemented when the condition will be true and false. "if" block will execute when the condition is true and "else" block will execute when the condition is false.

Syntax of IF-ELSE:-

## Statements

### Q) WAP to check that the entered number is a one-digit number or above one-digit number, the number can be positive or negative?

for example, if the user presses -1 then one digit, 9 then one digit, 20 then above one digit

num = int(input("enter number"))

if num>=-9 and num<=9:
print("one digit number")
else:
print("above one digit")

Assignment of IF-ELSE Statement:-

1)  WAP to increase the Salary of an employee from 500 if the entered salary is less than 10000 otherwise increase by 800?

2) WAP to Check Leap Year?

3) WAP to check number is positive or negative?

3)  Nested If--else:-

It is used to implement "multiple condition-based problems" that can not be solved by simple if-else.

it will use more than one if-else statement using a nested sequence means it contains collections of outer if-else and inner if-else.

if the program has multiple conditions and we do not use the logical operator(and) then we prefer nested if-else.

we should manage the nested sequence should be managed by Indent to create the outer block and inner block.

Python not prefer nested block mostly because indentation management is tuff hence python provides "elif" block to manage this.

Syntax of Nested If--Else:-

### statement

Q) WAP to check that entered number is one digit positive number, negative or two-digit positive number or negative?

num = int(input("enter number"))

if num>=-9 and num<=9:
if num>0:
print("one digit positive number")
else:
print("one digit negative number")
else:
if num>=10 and num<100:
print("two digit positive number")
else:
if num>=-99 and num<=-10:
print("two digit negative number")
else:
print("other number")

Q WAP to check the greatest number?

a = int(input("enter first number"))
b = int(input("enter second number"))
c = int(input("enter third number"))
if a>b:
if a>c:
print("a is greatest")
else:
print("c is greatest")
else:
if b>c:
print("b is greatest")
else:
print("c is greatest")

4)  Ladder if-else using elif statement:-

It provides a simple syntax structure as compare to nested if-else .ladder if-else will work step by step means if the first condition will be true then it will execute it, if it will be false then execute elif block at last if all condition will be false then else statement will execute.

Syntax of Elif Statement or Ladder IF-ELSE:-

## statement

................................................................................................

a = int(input("enter first number"))
b = int(input("enter second number"))
c = int(input("enter third number"))

if a>b and a>c:
print("a is greatest")
elif b>c:
print("b is greatest")

else:
print("c is greatest")

num = int(input("enter number"))
if num>=-9 and num<0:
print("one digit negative number")
elif num>0 and num<=9:
print("one digit postive number")
elif num>=-99 and num<-9:
print("two digit negative number")
else:
print("two digit positive number")

5) Multiple If:-

If we require MULTIPLE CONDITION WITH MULTIPLE RESULTS then we use multiple if,
We can create more than one if statement to check multiple conditions and it will provide multiple results.

### Q WAP to check divisibility of number from 3,5 and 9 with all combination:-

num = int(input("enter number"))
if num%3==0:
print("divisible by 3")
if num%5==0:
print("divisible by 5")
if num%9==0:
print("divisble by 9")

## Q) WAP to check that entered input is numeric char or alphabet char?

ch = input("enter char")
if ord(ch)>=48 and ord(ch)<=57:
print("Numeric")
elif (ord(ch)>=65 and ord(ch)<=90) or (ord(ch)>=97 and ord(ch)<=122):
print("Alphabet")
else:
print("Other")

## A solution to this program:-

num = int(input("enter number to check middle number"))
a= num%10  #3
num=num//10 #12
b=num%10   #2
c=num//10   #1

if a>b and a<c or a>c and a<b:
print(str(a)+" is middle number")
if b>a and b<c or b>c and b<a:
print(str(b)+" is middle number")
if c>a and c<b or c>b and c<a:
print(str(c)+" is middle number")

### Q) WAP to check that entered char is vowel and consonant without using or operator?

ch = input("enter char")

if ch=='a':
print("Vowel")
else:
if ch=='e':
print("Vowel")
else:
if ch=='i':
print("vowel")
else:
if ch=='o':
print("vowel")
else:
if ch=='u':
print("vowel")
else:
print("Consonent")

## The solution to this program:-

/* This is for User Input  */

s1= input("enter first subject name")
m1 = int(input("enter marks"))
s2= input("enter second subject name")
m2 = int(input("enter marks"))
s3= input("enter third subject name")
m3 = int(input("enter marks"))
s4= input("enter fourth subject name")
m4 = int(input("enter marks"))
s5= input("enter fifth subject name")
m5 = int(input("enter marks"))

if((m1>=0 and m1<=100) and (m2>=0 and m2<=100) and (m3>=0 and m3<=100) and (m4>=0 and m4<=100) and (m5>=0 and m5<=100)):
c=0
g=0
sub=""
dist=""

/*  check pass, fail and suppl according to c variable */

if m1<33:
c=c+1
g=m1
sub=sub+s1
if m2<33:
c=c+1
g=m2
sub=sub+s2
if m3<33:
c=c+1
g=m3
sub=sub+s3
if m4<33:
c=c+1
g=m4
sub=sub+s4
if m5<33:
c=c+1
g=m5
sub=sub+s5

/*  Check Distinction */

if m1>=75:
dist=dist+s1+" "
if m2>=75:
dist=dist+s2+" "
if m3>=75:
dist=dist+s3+" "
if m4>=75:
dist=dist+s4+" "
if m5>=75:
dist=dist+s5+" "

/*  it is used to manage pass, fail and supp according to c value*/

if c==0 or (c==1 and g>=28):
per= (m1+m2+m3+m4+m5)/5
if per>33 and per<45:
print("pass with third division")
elif per<60:
print("pass with second division")
else:
print("pass with first division")
if(dist!=""):
print("distinction subject name is "+dist)

if c==1:
print("pass by grace and grace mark is "+str(33-g)+" subject is "+sub)

elif c==1:
print("suppl")
else:
print("fail")
else:
print("entered subject marks should be 0 to 100")

### 11) WAP to check that salary is in income tax criteria or not. if in income tax then display income tax slab.

If you have any doubt in programming or join online classes then you can contact us by comment .

1. # increase salary of employee from 500 if entered salary will be less then 10000 otherwise same salary will be displayed.

salary=int(input(" Enter the employee salary :"))
if(salary<10000):
salary=salary+500;
print("\n Total salary of employee is :",salary)

2. #display mark of student which will be entered by the user's ,if mark is eligible for grace then display mark including grace mark otherwise actual mark will display.
marks=int(input("Enter the marks : "))
if marks>=28 and marks<33:
grace=33-marks
print("\nEligibal for grace ",grace)
marks=marks+grace

print("\n Total marks after grace ",marks )

3. #check that entered number is one digit number or above one digit number ,number can be positive or negative?
number=int(input("Enter the number :"))
if(number>=9 or number<=-9):
#if(number<-9):
print("\n Above one digit numner")
else:
print("\n It's one digit number")

4. # check that entered number is one digit positive number,negative or two digit positive number or negative ,number can be positive and negative?
number=int(input("Enter the number : "))
if(number>=9 or number<=-9):
print("\n Above one digit numner")
else:
print("\n It's one digit number")
if(number>=0):
print(" \n Number is positive")
else:
print("\n Number is negative")

5. #check divisibility of number from 3,5 and 9 with all combination:-
number=int(input(" Enter the number : "))
'''if(number%3==0 or number%5==0 or number%9==0):
print("\n Number can be devide with given number : ")
else:
print("\n Number can't be devide with given number : ")'''
if number%3==0:
print("\n Number can be devide with number 3 ")
if number%5==0:
print("\n Number can be devide with number 5 ")
if number%9==0:
print("\n Number can be devide with number 9 ")
else:
print("\n Number can't be devide with number")

6. Program to check leap year-->

a=int(input("enter the year"))
if a%4==0:
print("it is leap year")
else:
print("it is not leap year")

7. #WAP to Calculate Marksheet using five different subjects with the following condition.
# all subject marks should be 0 to 100.
s1=input("enter 1st subject name")
m1=int(input("enter 1st subject marks"))
s2=input("enter 2nd subject name")
m2=int(input("enter 2nd subject marks"))
s3=input("enter 3r subject name")
m3=int(input("enter 3rd subject marks"))
s4=input("enter 4th subject name")
m4=int(input("enter 4th subject marks"))
s5=input("enter 5th subject name")
m5=int(input("enter 5th subject marks"))
if (m1>=0 and m1<=100) and (m2>=0 and m2<=100) and (m3>=0 and m3<=100) and (m4>=0 and m4<=100)and (m5>=0 and m5<=100):
print("all subject between 1 to 100")
else:
print("all subject not between 1 to 100")

8. # WAP to check that salary is in income tax criteria or not. if in income tax then display income tax slab.
sal=int(input("enter gross salary"))
i=''
if(sal>200000):
i=i+str(sal//4)#25% of income
print("incometax slab",i)
else:
print("salary not come in income tax slab")

9. #if only one subject mark is <33 then the student will be suppl.
s1=input("enter 1st subject name")
m1=int(input("enter 1st subject marks"))
s2=input("enter 2nd subject name")
m2=int(input("enter 2nd subject marks"))
s3=input("enter 3r subject name")
m3=int(input("enter 3rd subject marks"))
s4=input("enter 4th subject name")
m4=int(input("enter 4th subject marks"))
s5=input("enter 5th subject name")
m5=int(input("enter 5th subject marks"))
#if (m1>=0 and m1<=100) and (m2>=0 and m2<=100) and (m3>=0 and m3<=100) and (m4>=0 and m4<=100)and (m5>=0 and m5<=100):
c=0 #compartement
if (m1<33)or (m2<33) or (m3<33)or (m4<33)or (m5<33):
print("student will be supplymentry")
else:
print("student pass")

10. to check that salary is in income tax criteria or not--->>

salary=int(input("enter total salary"))

if(salary>250000):
i=(salary*5/100)
print("income tax slab",i)
else:
print("salary is not in income tax slab")

11. Program to display "YES" and "NO" when user press 'y' and 'n'---->>>

ch = input("enter char")

if ch=='y':
print("yes")
else:
if ch=='n':
print("no")

12. Lokesh Rathore

Increase the salary of employees from 500 if entered salary will be less than 10000 otherwise the same salaries will be displayed ??
Solution:-
sal = int(input("Enter Salary of Employee :- "))
if sal<10000:
sal=sal+500
print(sal)

13. Lokesh Rathore

Check that entered number is one digit positive number, negative or two-digit positive number or negative ??
Solution:-
n = int(input("Enter number :- "))

if n>=-9 and n<=9:
print("One Digit Number.")
else:
print("It's Above One Digit Number.")

14. Lokesh Rathore

WAP to increase the Salary of an employee from 500 if the entered salary is less than 10000 otherwise increase by 800?

Solution:-
sal=int(input("Enter salary of Employee :- "))
if sal<10000:
sal=sal+500
print(sal)
else:
sal = sal+800
print(sal)

15. Lokesh Rathore

WAP to Check the Leap Year using IfElse ?
Solution :-
year= int(input("Enter Year :- "))
if year%4==0:
print("This is Leap Year.")
else:
print("This is not Leap Year.")

16. Lokesh Rathore

WAP to check the number is positive or negative using If Else ??

Solution :-
num=int(input("Enter a Number :- "))
if num<0:
print("This is Negative Number.")
else:
print("This is Positive Number.")

17. Lokesh Rathore

Program to display "YES" and "NO" when user press 'y' and 'n' ??
Solution:-
char = input("Enter your choise y/n :- ")
if char=='y':
print("yes")
else:
if char=='n':
print("no")

18. Lokesh Rathore

WAP to calculate greatest using four different number using nested and ladder both?
Solution :-
a = int(input("Enter first number :-"))
b = int(input("Enter second number :- "))
c = int(input("Enter third number:- "))
d = int(input("Enter fourth number :- "))
if a>b:
if a>c:
if a>d:
print("A is Greatest Number.")
else:
print("D is Greatest Number.")
else:
if c>d:
print("C is Greatest Number.")
else:
print("D is Greatest Number.")
else:
if b>c:
if b>d:
print("B is Greatest Number.")
else:
print("D is Greatest Number.")
else:
if c>d:
print("C is Greatest Number.")
else:
print("D is Greatest Number.")

19. Lokesh Rathore

WAP to check that entered char is vowel and consonant without using or operator?
Solution :-
char = input("Enter character :- ")
if char=='a':
print("It is Vowel.")
else:
if char=='e':
print("It is Vowel.")
else:
if char=='i':
print("It is Vowel.")
else:
if char=='o':
print("It is Vowel.")
else:
if char=='u':
print("It is Vowel.")
else:
print("It is Consonent.")

20. deependra singh jadaunNovember 5, 2020 at 10:18 AM

program for salary increment below 10000 salary
s=int(input("enter salary of employee"))
i=s+500
if (s<10000):
print("your salary is increased by 500; becomes {} ".format(i))
else:

21. deependra singh jadaunNovember 5, 2020 at 4:42 PM

wap to check greatest no. when four nos. are given.
a=int(input("enter first no."))
b=int(input("enter second no."))
c=int(input("enter third no."))
d=int(input("enter fourth no."))

if a>b and a>c:
if a>d:
print('str(a)'"is greatest")
else:
if b>a and b>c:
if b>d:
print("b is greatest")
else:
if c>a and c>b:
if c>d:
print("c is greatest")
else:
if d>a and d>b:
if d>c:
print("d is greatest")

22. deependra singh jadaunNovember 6, 2020 at 10:53 AM

#wap to check vowel or consonant without "or"
ch=input("enter any character")
if ch=='a':
print("vowel")
elif ch=='e':
print("vowel")
elif ch=='i':
print("vowel")
elif ch=='o':
print('vowel')
elif ch=='u':
print("vowel")
else:
print("consonant")

23. deependra singh jadaunNovember 6, 2020 at 10:55 AM

#program to check greatest no. out of three given nos.
a=int(input("enter first no"))
b=int(input("enter second no."))
c=int(input("enter third no."))

if a>b and a>c:
print("a is greatest")
else:
if b>c and b>a:
print("b is greatest")
else:
if a==b==c:
print("no. are equal")
else:
print("c is greatest")

24. deependra singh jadaunNovember 6, 2020 at 10:59 AM

#
Q) WAP to check that the entered number is a one-digit number or above one-digit number, the number can be positive or negative?
x=int(input("enter any no."))
if -9<=x<=9:
if x<=9 and x>0:
print("no. is one digit positive")
else :
if x>=-9 and x<0:
print("one digit negative no.")
else:
x=0
print("zero no.")
else:
if x>9 and x<=99:
print("two digit positive no.")
else:
if x<-9 and x>=-99:
print("two digit negative no.")
else:

print("other no.")