00 : 00 : 00 ... aaa / aaa / aaa ... aaa

A basic program in python

Do you wanna learn python with some example codes?
Then I wanna give you this code
This uses very basic things to let you know how to code in python.
It takes length and breadth of a rectangle as input and prints it's area and perimeter.
That's very basic.
You can comment down if you don't understand any of the lines in code.
So here's the code:

#Program to find area and perimeter of a rectangle whose parametrs are given by the user

#Let's welcome the user with his name

#First take his name into n variable
n = raw_input("Enter your name: ")
#Now print welcome along with his name
print  "Welcome",n

#Now let's take input form the user
l = input("Please enter length: ")
b = input("Please enter breadth: ")

#Let's find the area and perimeter and store them in variables a and p respectively
a = l * b
p = 2*(l+b)

#Now let's print area and perimetr
print "Area:", a," cm2"
print "Perimeter:", p, " cm"

print "Thank you for using the code"

#Hope you guys like it and understand basic concepts in python
#Created by Tinkerbench. https://tinkerbenchlabs.blogspot.com/

--------------------End of code--------------------------

Thank you


  1. If you find this thing difficult to understand, please comment down what you don't understand.


Post a Comment

Popular posts from this blog

Chat program in batch