₹2,000.00 ₹300.00
The Python Programming Language at Champak's World
  • 22 students
  • 41 lessons
  • 0 quizzes
  • 10 week duration


Input Output in Python

Input Output in python . Let’s understand this. How  does  we take input and output in python . Take a name of variable of your choice assign them with sum value like if you take a variable name i.e.(A) and assign value to a is like A=5. This is how declaration of variable is done in python .
Now you have a question  that can only we can assign numeric values in variable or we can  assign string (means alphabet )  in variable, so answer is that yes! you can assign .
Here is code of a small program  of adding of two number in python.

Input Output in python 
a=5       # Declaration of 1st variable
b=7       # Declaration of 2st variable
c=a+b       #Storing value in third variable
print("This is result of adding your above declaration= ",c) 

Now look at above  program . There is no declaration of datatype when we are taking values in the program
Here is something different  by default python put it’s all undeclared values as string type. But what in case you have to take input of desired data type. Program is below

Arithmetic Operators 
A program of Simple Interest
p=float(input("Enter Principle Value"))
t=float(input("Enter time "))
r=float(input("Enter rate of interest"))
print("This is value of simple interest",si)

Have a look on “p” variable . First we declare variable than data type then input function
variable=data_type(input(“Enter Your Value”))
As default program will return value in string type if you wish to take return value in another datatype.It can be done simply  (si=float(p*t*r/100.0)
Output Of above program is

Enter Principle Value1000

Enter time 1

Enter rate of interest2
This is value of simple interest 20.0

Commenting in Python

Commenting is very useful in every programming language. Commenting  make clear to a non programmer that how programm is done  or when you make some long program like 200-500
lines of program which you must have to comment your program . Comment sentence are not include in interpreting process. Means it is not read by by interpreter as programming command.
In Python both Single line and multiline commenting are allowed. Single line commenting are done by #
and multi line commenting are done between (  ”’   Comment  ””. ). In above code of add you can see that how commenting is done.

Leave a Reply

Your email address will not be published. Required fields are marked *