Please explain this code and output to me | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 2

Please explain this code and output to me

It's a python code explain the working of code line by line which thing does what? https://code.sololearn.com/caGEo89Jzwyi/?ref=app

11th Aug 2021, 8:17 AM
Silentmaster8506
Silentmaster8506 - avatar
7 Answers
+ 5
Please read python language, don't ask that 'what is this'!! We aren't teachers. You have downloaded the SOLOLEARN app for what?? For learning right? Then learn!
11th Aug 2021, 8:48 AM
Parth
Parth - avatar
+ 4
it is always good to know how these things can be solved by using an algorithm. just to mention, that there is a bin() function that can do this also: a=[10,11,12,13] for num in a: print("---",bin(num)[2:]) # [2: ] is a slice that cut out only the numbers part of the binary string "0b1010"
11th Aug 2021, 10:10 AM
Lothar
Lothar - avatar
+ 3
Silentmaster8506 This problem is converting number to binary numbers Explanation is given in code. I have just explained for number 10 now try to understand for other numbers. https://code.sololearn.com/cS2u690xrQ2V/?ref=app
11th Aug 2021, 9:10 AM
A͢J
A͢J - avatar
+ 2
Silentmaster8506 it's binary representation of decimal numbers 10,11, 12, 13 in decimal in binary(base2) 10 -----> 1010 11 -----> 1011 12 -----> 1100 13 -----> 1101
11th Aug 2021, 9:11 AM
Ratnapal Shende
Ratnapal Shende - avatar
+ 1
Silentmaster8506 Google "how to convert a decimal into a binary number" and you'll understand it.
11th Aug 2021, 9:39 AM
Calvin Thomas
Calvin Thomas - avatar
+ 1
The f-string also has such a functionality.
11th Aug 2021, 10:37 AM
Calvin Thomas
Calvin Thomas - avatar
+ 1
#f-string num=12 print(f"{num:b}")
11th Aug 2021, 3:01 PM
Ratnapal Shende
Ratnapal Shende - avatar