Ask Question

Make a program that asks for input from the user, apply eval to this input, and print out the type of the resulting object and its value. Test the program by providing five types of input: an integer, a real number, a complex number, a list, and a tuple.

+3
Answers (1)
  1. 5 August, 14:21
    0
    x = input ("Input a number ")

    print (eval ("x"))

    print ("Type is:", type (x))

    #Taking an float input

    y = input ("Input a number ")

    print (eval ("y"))

    print ("Type is:", type (y))

    #Taking an complex input

    z = complex (input ("Input a number "))

    print (eval ("z"))

    print ("Type is:", type (z))

    #Taking an List input

    L_num = raw_input (). split (",")

    print (eval ("L_num"))

    print ("Type is:", type (L_num))

    #Taking an tuple input.

    T_num = raw_input (). split (",")

    print (eval ("T_num"))

    print ("Type is:", type (T_num))
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Make a program that asks for input from the user, apply eval to this input, and print out the type of the resulting object and its value. ...” 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