Loading, please wait...

Logic and Syntax

Pre-Requestics For Writing Code in Python

 

1. Print a sentence

Writing a code in python to print something is really fun than any.

 

To print something in python we need just to type

Print(“Your message here”)

And we are good to go!!

 

Ex:-

Print(“Hi this is Team TL”)

 

 

2. Decision making statement

 

  • The very first one is the very known “IF” statement
var = 250
if ( var == 250 ) :
print "Value of expression is twofifty"
print "Good bye!"

 

  • Second only comes “IF-ELSE
var = 10
if ( var == 10 ) : print "Value of expression is 10"
print "Good bye!"
else:
print “Not 10”

 

  • The elif function
if test expression:

Body of if
elif test expression:

Body of elif

else:
Body of else