IF Else - Conditional Operators in Python - Part 4

preview_player
Показать описание
#Python #PythonProgramming

In this video, we will learn about If-Else in Python.

Learn:
1. IF Else in Python
2. Different features of If Else:
-Single If statement
-If with else if statement
-nested if - else if
--Find out the highest number where three numbers are given

~~~Subscribe to this channel, and press bell icon to get some interesting videos on Selenium and Automation:

Follow me on my Facebook Page:

Let's join our Automation community for some amazing knowledge sharing and group discussion on Telegram:

WebServices API Automation Tutorials:

Follow me on my Facebook Page:

Let's join our Automation community for some amazing knowledge sharing and group discussion on Telegram:

Paid courses (Recorded) videos:
📗 Get My Paid Courses at
Paid courses (Recorded) videos:
-------------------------------

✔️SOCIAL NETWORKS
--------------------------------

Support My Channel✔️Or Buy Me A Coffee
--------------------------------
✔️Thanks for watching!
देखने के लिए धन्यवाद
Благодаря за гледането
感谢您观看
Merci d'avoir regardé
Grazie per la visione
Gracias por ver
شكرا للمشاهدة
Рекомендации по теме
Комментарии
Автор

a=int(input("Enter A number"))
b=int(input("Enter B number"))
c=int(input("Enter C number"))
d=int(input("Enter D number"))

if(a>=b and a>=c and a>=d):
print("A is the greatest number")
elif(b>=c and b>=d):
print("B is the greatest Number")
elif(c>=d):
print("c is the greatest Number")
else:
print("d is the greatest Number")

prabhakarbharath
Автор

a=int(input("Enter the value of a "))
b=int(input("Enter the value of b "))
c=int(input("Enter the value of c "))
d=int(input("Enter the value of d "))
print("Entered values are a = "+str(a)+", b = "+str(b)+", c = "+str(c)+", d = "+str(d))
if a>b and a>c and a>d:
print("a is the highest among all numbers")
elif b>c and b>d :
print("b is the highest number")
elif c>d:
print("c is the highest number")
else:
print("d is the highest number")

foreverpraan
Автор

Naveen here is the code for find greatest among 4 values:
a = int(input("please enter the a value:"))
b = int(input("please enter the b value:"))
c = int(input("please enter the c value:"))
d = int(input("please enter the d value:"))

if a>b and a>c and a> d:
print ("a is highet")
elif b>c and b>d:
print("b is highest")
elif c>d :
print("c is highest")
else:
print("d is highest")

tharunit
Автор

Thanks Naveen, I'm loving this series.

ruchitsharma
Автор

class Greatest_Four_No:
# Global Declaration of the Input by the user
a = int(raw_input("Please enter the first no : "))
b = int(raw_input("Please enter the second no : "))
c = int(raw_input("Please enter the third no : "))
d = int(raw_input("Please enter the fourth no : "))
# Method to find out the maximum using max function
def find_greatest_no(self):
max_no = max(self.a, self.b, self.c, self.d)
return max_no
# Method to find out the maximum using nested if statment(Conditional Statment)
def find_Greatest_no(self):
if self.a >self.b and self.a > self.c and self.a >self.d:
print "The highest no is {}".format(self.a)
elif self.b > self.c and self.b >self.d:
print "The highest no is {}".format(self.b)
elif self.c > self.d:
print "The highest no is {}".format(self.c)
else :
print "The highest no is {}".format(self.d)

# Object Declaration
Maximum =Greatest_Four_No()
print "The highest no is {}
Maximum.find_Greatest_no()

aska
Автор

I think this is 3 rd way to print..another than str type casting and f string
Print('total', total)

herocartoonizer
Автор

a = 500
b = 200
c = 800
d = 400

if a>b and a>c and a>d :
print('a is maximum')
elif b>c and b>d :
print('b is maximum')
elif c>d :
print('c is maximum')
else :
print('d is maximum')

SUNILKUMAR-ufym
Автор

Hi Sir I have completed the assignment of finding the highest number among 4 please find the program


a=100
b=200
c=300
d=400

if a>b and a>c and a>d:
print("A is the highest number")
elif b>c and b>d:
print("B is the highest number")
elif c>d:
print("C is the highest number")
else:
print("D is the highest number")

nandinivijay
Автор

program to find largest out of 4 numbers
a =1
b=2
c=3
d=4
if a>b and a>c:
print(a)
elif b>c and b>d:
print(b)
elif c>d:
print(c)
else:
print(d)

positionalstockexpert
Автор

Highest value in 4 numbers:


a = 100
b = 200
c = 300
d = 400


if a>b and a>c and a>d:
print("a is the highest")
elif b>c and b>d:
print("b is the highest")
elif c>d:
print("c is the highest")
else:
print("d is the highest")


but it doesn't checking same values

nandhanamtalkies
Автор

Hi Naveen, could you please tell me why my conditions are not checked for the total script
total = int(input("Enter the value of total :"))
if total < 100:
total = total + 50
elif 100 >= total <= 500:
total = total + 10
else:
total = total + 200
print(total)


I am able to see Enter the value of total in console but none of the condition is getting printed

akanshasharma
Автор

Last eg for concatination of total...we can also simply give a come in order to =', total)

venunisani
Автор

#WAP to find out highest number between four numbers

a=100
b=200
c=300
d=400

if(a>b and a>c and a>d):
print("a is highest number")
elif(b>a and b>c and b>d):
print("b is highest number")
elif(c>a and c>b and c>d):
print("c is highest number")
else:
print("d is highest number")


O/P:d is highest number

JAYITAMs
Автор

hi naveen, when you will be starting Selenium with Python.. i am waiting for those videos. Current phython videos are awesome

amrita
Автор

a=400
b=500
c=700
d=600
if a>b and a>c and a>d:
print("a ix Highest")
elif b>c and b>d:
print("b is Highest")
elif c>d:
print("c is Highest")
else :
print("d is the Highest")

avinashnadhe
Автор

a=100
b=200
c=300
d=400
if a>b and a>c and a>d :
print("a is greater")
elif b>c and b>d :
print("b is greater")
elif c>d :
print("c is greater")
else :
print("d is greater")

kangulapavan