Predict the output of the following:
Print(52*7)
Print("52*7")
Print("52*7=",52*7)
Print("52"*7)
Answers
Answer:
1. 364
2. 52*7
3. 52*7=364
4. 52525252525252
The first line print(52*7) is a basic multiplication operation where the result is computed and then printed to the console using the print() function. Since the multiplication operation is between two numbers, the result is a numeric value, and hence the output is simply the numeric value 364.
The second line print("52*7") is a simple string that contains the characters "52*7" and is enclosed in double quotes. When this line is executed, the print() function simply prints the string as it is, which means the output will be the string 52*7.
The third line print("52*7=", 52*7) combines a string and a numeric value using the + operator to create a new string that is then printed to the console. In this case, the resulting string is 52*7=364, and hence that is the output produced by this line.
The fourth line print("52"*7) uses the * operator with a string on the left-hand side to repeat the string a specified number of times. In this case, the string "52" is repeated seven times to produce the string 5252525252, which is then printed to the console.
#SPJ3