- 10

What is the output of this code? >>> print(3 * '7')

What is the output of this code? >>> print(3 * '7')

3rd Jun 2019, 8:08 AM
Odinaka Ugwumba
Odinaka Ugwumba - avatar
11 Respuestas
+ 4
it should be 777, i think you should run this yourself and dont ask question about this unless you dont understand, what happen
3rd Jun 2019, 8:10 AM
✳AsterisK✳
✳AsterisK✳ - avatar
+ 3
Denise Roßberg In Python (3 * '7'), repeats the string '7' three times. Example: (4 * '!') => !!!!
3rd Jun 2019, 12:23 PM
Solo
Solo - avatar
+ 2
*AsterisK* Interresting. In Java it would be 165 (3 *55).
3rd Jun 2019, 9:01 AM
Denise Roßberg
Denise Roßberg - avatar
+ 2
Seb TheS I know it. But it is interesting that the output in python is 777 and not 165.
3rd Jun 2019, 10:23 AM
Denise Roßberg
Denise Roßberg - avatar
+ 1
Python: 777; console.log(3*'7'); // 21; What will be the conclusion: 1) echo 3*'7'; 2) cout << 3*'7'; 3) Console.WriteLine(3*'7'); 4) System.out.println(3*'7');
3rd Jun 2019, 8:17 AM
Solo
Solo - avatar
0
Denise Roßberg '7' is a character and characters can be converted to integers by the character position in a constant list of all the available characters. When '7' is converted to integer it returns value 55.
3rd Jun 2019, 9:26 AM
Seb TheS
Seb TheS - avatar
0
777
3rd Jun 2019, 10:46 AM
CodeFu
CodeFu - avatar
0
777
14th Jun 2020, 7:59 AM
Emmanuel s, Brown
Emmanuel s, Brown - avatar
0
34 answer
14th Jun 2020, 8:02 AM
Emmanuel s, Brown
Emmanuel s, Brown - avatar
0
777
18th May 2021, 10:51 AM
Limitha M
Limitha M - avatar
0
It's 777
13th Oct 2021, 3:08 AM
DomainMan