Ask Question
31 October, 09:07

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.

+4
Answers (1)
  1. 31 October, 10:26
    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?
Get 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 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