1

Jul 24, 2015

Python Tutorial : If Else condition

Here is the syntax for if else condition in Python:

pencils = 80
students = 20
distribution=pencils/students
if distribution>=4 :   print("OK")
else:    print("NOT OK")

This code checks whether every student get minimum 4 pencils or not. If yes, then print "OK" or print "NOT OK".


Python Tutorial : Double condition in IF

If you have a double conditions scenario in python, you can use the below code. Make sure you press TAB button after : otherwise you might get "Indent Block" error.

today = "Monday"
if today =="Monday" or today == "Wednesday" :    print ("Swimming classes")

Python Tutorial : Make HTML

You can use HTML tags in python to style your text.

dish = "pasta"
print("<b>" + dish + "</b>")
print("<h1>" + dish + "</h1>")

Python Tutorial : Concatenate and Print

Here is the tutorial for using print command and how we can concatenate the string with variables.

favorite_vegetable = "asparagus"
favorite_entree = "noodles"

print("My favorites are " + favorite_vegetable + " and " + favorite_entree)

Related Post

Related Posts Plugin for WordPress, Blogger...