Determine what is printed by the following program listinput.py,
list1 = eval(raw_input(‘Give a list:’))
list2 = eval(raw_input(‘Give another list:’))
print list1 + list2
When the program is running as follows:
Unix/DOS > python listinput.py
Give a list: ‘[1,2]’
Give another list: "[3,4]"
Answers
Answered by
2
Explanation:
The syntax is as follows for Python v2.x:
mydata = raw_input('Prompt :')
print (mydata)
The syntax is as follows for Python v3.x as raw_input() was renamed to input() :
mydata = input('Prompt :')
print (mydata)
In the above example, a string called mydata stores users data. Please note that if you want to compare mydata
Answered by
0
The following program will print [1, 2][3,4].
- The program is the Pythin language program
- The program is using eval(s). Eval(s) evaluates any expression which is contained in the string s and hence returns a resulting object.
- In the given program, both the inputs are strings. A symbol ( + ) between the strings means to concatenate the strings, that is setting the second string right after the first one.
- Thus, as a result the program will execute [1, 2][3,4].
Similar questions
Math,
5 months ago
Hindi,
5 months ago
Computer Science,
10 months ago
Computer Science,
10 months ago
English,
1 year ago