+ 2

Can any one tell me, how this work? (python)!

x = '101' y = int(x, 2) print('x =', x) print('y =', y) x = 101 y = 5

9th Dec 2020, 1:31 PM
HASHIM AL-EDRESI
HASHIM AL-EDRESI - avatar
5 Respuestas
+ 4
x = '101' y = int(x, 2) print('x =', x) print('y =', y) x = 101 y = 5 x is already defined. Hope you know that. y = int(x, 2) It converts a string representing a binary number likewise, y= int(x,8) It converts it to octal Btw, 101 represents 5 in decimal
9th Dec 2020, 1:45 PM
Simba
Simba - avatar
+ 3
y = int(x,2) # 2 = 101 convert to binary to be 5 if you want to print 101 change 2 to 10
9th Dec 2020, 1:44 PM
Kirollos Samir
Kirollos Samir - avatar
+ 1
Which language
9th Dec 2020, 1:35 PM
🥇👩‍💻 Kintu Michael Evans 🔥🔥( Active)
🥇👩‍💻 Kintu Michael Evans 🔥🔥( Active) - avatar
+ 1
Simba that is a good explanation
9th Dec 2020, 1:46 PM
🥇👩‍💻 Kintu Michael Evans 🔥🔥( Active)
🥇👩‍💻 Kintu Michael Evans 🔥🔥( Active) - avatar
0
HASHIM AL-EDRESI the code just prints the variable x and y
9th Dec 2020, 1:42 PM
🥇👩‍💻 Kintu Michael Evans 🔥🔥( Active)
🥇👩‍💻 Kintu Michael Evans 🔥🔥( Active) - avatar