0% found this document useful (0 votes)
20 views1 page

Input Function and Programs

The document explains the use of the input() function in Python, which reads data from the keyboard and returns it as a string. It provides syntax examples and demonstrates how to convert input strings to integers for arithmetic operations. Additionally, it includes several programming exercises related to distance conversion, time calculation, simple interest, area calculations, arithmetic operations, and finding averages.

Uploaded by

stchardwar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views1 page

Input Function and Programs

The document explains the use of the input() function in Python, which reads data from the keyboard and returns it as a string. It provides syntax examples and demonstrates how to convert input strings to integers for arithmetic operations. Additionally, it includes several programming exercises related to distance conversion, time calculation, simple interest, area calculations, arithmetic operations, and finding averages.

Uploaded by

stchardwar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

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.

You might also like