Explanation:
Line 1: print(3 * "7")
This line prints the result of multiplying the string "7" by the integer 3.
Breaking it Down
3 is an integer.
"7" is a string because it is enclosed in quotes.
In Python, multiplying a string by an integer repeats the string that many times.
So, "7" * 3 becomes:
"777"
print() displays the repeated string on the screen.
How Python Evaluates It
3 * "7"
Step 1:
"7"
A string containing one character.
Step 2:
"7" * 3
Repeat "7" three times.
Step 3:
"777"
Step 4:
print("777")
Displays the output.
Output
777

0 Comments:
Post a Comment