0% found this document useful (0 votes)
26 views5 pages

Fs20co047 Py Exp 10

The document discusses taking input in Python using the input() and raw_input() functions. It explains how input() works, how to take different data types as input like integers, floats and strings, and provides an example program to take biodata input from the user and print it.
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)
26 views5 pages

Fs20co047 Py Exp 10

The document discusses taking input in Python using the input() and raw_input() functions. It explains how input() works, how to take different data types as input like integers, floats and strings, and provides an example program to take biodata input from the user and print it.
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/ 5

1

FS20CO047
Experiment 10

Shrikrushna Dilip Patil


2

Title: Write a Python program to display a message on the screen..


Theory:
1. Taking input in Python
Developers often have a need to interact with users, either to get
data or to provide some sort of result. Most programs today use a
dialog box as a way of asking the user to provide some type of input.
While Python provides us with two inbuilt functions to read the input
from the keyboard.

input ( prompt)

raw_input ( prompt )

This function first takes the input from the user and then
evaluates the expression, which means Python automatically
identifies whether user entered a string or a number or list. If
the input provided is not correct then either syntax error or
exception is raised by Python.

2. How the input function works in Python:-


When input() function executes program flow will be
stopped until the user has given an input.

The text or message display on the output screen to ask a


user to enter input value is optional i.e. the prompt, will be
printed on the screen is optional.

Whatever you enter as input, input function convert it into a


string. if you enter an integer value still input() function
convert it into a string. Raw_input():

This function works in older version (like Python 2.x). This


function takes exactly what is typed from the keyboard,
convert it to string and then return it to the variable in which
we want to store.
3

3. Accepting Input from Console


User enters the values in the Console and that value is then
used in the program as it was required. To take input from the
user we make use of a built-in function input().

4. Typecasting the input to Integer:


There might be conditions when you might require integer input
from user/Console, the following code takes two input(integer/float)
from console and typecasts them to integer then prints the sum.

5. Typecasting the input to Float:


To convert the input to float the following code will work out.

6. Typecasting the input to String:


All kind of input can be converted to string type whether they are
float or integer. We make use of keyword str for typecasting.

Program to Print your biodata, including your name, Enrollment Number,


ResidentialAddress, Email ID, Contact Number, etc to console. Take input
using input() methodand save data in appropriate variables and then print to
console.
4

Practical:
a. Program to Print your biodata, including your name,
Enrollment Number, ResidentialAddress, Email ID, Contact
Number, etc to console. Take input using input() methodand
save data in appropriate variables and then print to console.

Program:-

Observation:
a.
Output:-
5

Conclusion:
Thus, we have seen how to take input from the user. We
have performed program related to this

You might also like