If-Else statements and its significance:
"If-else" statements are a type of conditional statements in programming which allows specific logic or conditions to be given to different blocks of code. It's literally creating a bias or condition to a code block. The benefits range from making decisions to controlling possibilities.
Practical example:
Lets say we want to write a code about weight information in such a manner that if the user is above 130kg He/She is overweight, see how we are going to write it.
Weight = int(input("enter your weight in kg here"))
if weight >= 130:
print("You are overweight ")
else:
print("You are good to go")
Principles you must apply:
Ensure to use small letters for your functions.
Keep it simple, avoid ambiguity.
Use ":" after 'else' to avoid error.
Use integer function "int" to indicate that the expected input value is a number not a letter.
Top comments (0)