Ask Question
20 March, 07:17

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. 20 March, 10:52
    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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers