Ask Question
10 February, 00:17

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. 10 February, 03:57
    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 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