0

Explanation of this code, please

Can someone tell me why this python code outputs 5 A = 1#2 B = "5" AB = B*A print (AB) Thanks

15th Apr 2018, 2:37 PM
sean
5 Answers
+ 1
# use in python for write a comment for example A=5*2 #the result is 10 the compiler execute just A=5*2 and leave everythings that comes after "#"
15th Apr 2018, 3:15 PM
before
+ 3
A = 1#2 # ==> comment in python so A =1 B="5" ==> B its string variable AB = B*A ==> "5"*1 that mean repeat "5" once times if was A = 3 the result equal 555
15th Apr 2018, 2:48 PM
before
0
A = 1#2 # ==> comment in python so A =1 Can you elaborate please?
15th Apr 2018, 3:05 PM
sean
0
Thank you. haven't been taught about that just yet.
15th Apr 2018, 3:46 PM
sean
0
a=1 #2 comments so a=1 b='5' ab=b*a print (ab) print (1×'5') so and is '5'
17th Apr 2018, 2:55 PM
rahul bisht
rahul bisht - avatar