Breaking News: Grepper is joining You.com. Read the official announcement!
Check it out

Input and Output Statements

Vinay Rawal answered on April 1, 2023 Popularity 8/10 Helpfulness 1/10

Contents


More Related Answers

  • Inpunt and output
  • Output Statements:

  • Input and Output Statements

    0

    In Python 2 the following 2 functions are available to read dynamic input from the

    keyboard.

    1) raw_input()

    2) input()

    1)raw_input():

    This function always reads the data from the keyboard in the form of String Format.

    We have to convert that string type to our required type by using the corresponding

    type casting methods.

    Eg: x = raw_input("Enter First Number:")

    print(type(x))  It will always print str type only for any input type

    2)input():

    input() function can be used to read data directly in our required format.We are not

    required to perform type casting.

    x = input("Enter Value)

    type(x)

    10  int

    "durga" str

    10.5  float

    True  bool

    ***Note:

     But in Python 3 we have only input() method and raw_input() method is not available.

     Python3 input() function behaviour exactly same as raw_input() method of Python2.

    i.e every input value is treated as str type only.

     raw_input() function of Python 2 is renamed as input() function in Python 3. 

    Popularity 8/10 Helpfulness 1/10 Language whatever
    Source: Grepper
    Link to this answer
    Share Copy Link
    Contributed on Apr 01 2023
    Vinay Rawal
    0 Answers  Avg Quality 2/10


    X

    Continue with Google

    By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.
    X
    Grepper Account Login Required

    Oops, You will need to install Grepper and log-in to perform this action.