Ask Question
21 September, 14:49

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. 21 September, 18:27
    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?
Get 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 there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers