The input () Function:
input () function is used to read the data from the keyboard but it returns
as a string.
Syntax:
Variable_name=input(“Message”)
Example1:
>>>name= input(“Enter your name:”)
Enter your name:arpit
>>> print(name)
arpit
Example2:
>>> a=input("enter a:")
enter a:10
>>> b=input("enter b:")
enter b:20
>>> print(a+b)
1020
Example4:
Example3: >>> a=input("enter a:")
>>> a=int(input("enter a:")) enter a:10
enter a:10 >>> b=input("enter b:")
enter b:20
>>> b=int(input("enter b:")) >>> print(int(a)+int(b))
enter b:20 30
>>> print(a+b)
30
Q.1 Write a program to read distance in miles and print in kilometre. (1
mile=1.609 km)
Q.2 Write a program to compute “how many days in a million seconds?”
Q.3 WAP to calculate simple interest by entering the value of principle amount,
rate of interest and time period.
Q.4 WAP to calculate the area of a rectangle by entering length and width.
Q.5 WAP to calculate the area of a triangle by entering height and base.
Q.6 WAP to enter two integers an perform all arithmetic operations on them.
Q.7 WAP to swap two numbers using a third variable.
Q.8 WAP to enter three numbers and find their average.