Ask Question

Input a string of digits. Convert the string to an int. Print the int. Convert the string to a float. Print the float.

+4
Answers (1)
  1. 12 May, 03:57
    0
    x_inp = [ '1', '2', '3']

    int_val = [ int (a) for a in x_inp ]

    print ("integer: int_val")

    y_inp = [ '1.0', '2.0', '3.0']

    flo_val = [ float (a) for a in y_inp ]

    print ("float: flo_val")

    Explanation:

    All the items in the arrays x_inp and y_inp are coverted to integer and float data types respectively with the for loop statement, which individually assigns the resolved integer and float values to the memory locations int_val and flo_val respectively.

    The output becomes,

    integer:

    1

    2

    3

    float:

    1.0

    2.0

    3.0
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Input a string of digits. Convert the string to an int. Print the int. Convert the string to a float. Print the float. ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers