if-else in Python
If block contains the condition, if condition is true, then the statements of if block will execute and if the condition is false then the statement of else block will execute.
if expression: statement(s) # statements must be indented else: statement(s) # statements must be indented
Block Diagram :
Example:WAP to check no. is +ive or -ive.
v = 5 if v >= 0: print("Number is positive or Zero") else: print("Number is negative") # Try for these values # v = -5 # v = 0OUTPUT
Number is positive or Zero
Next topic is if-elif-else in Python
Training For College Campus
We offers college campus training for all streams like CS, IT, ECE, Mechanical, Civil etc. on different technologies
C, C++, Data Structure, Core Java, Advance Java, Struts Framework, Hibernate, Python, Android, Big-Data, Ebedded & Robotics etc.
Please mail your requirement at firstname.lastname@example.org
Projects For Students
Students can contact us for their projects on different technologies Core Java, Advance Java, Android etc.
Students can mail requirement at email@example.com