0
I don't understand back slashes please help
7 Réponses
+ 5
In Python, backslashes have two uses.
5 / 2 = 2.5
Simple division, like in a calculator.
5 // 2 = 2
Floor division, will give you whole numbers but won't round, it will simply chop off the end. So, 2.5 usually rounds to 3, but with floor division, it just gets rid of it.
+ 5
Just saying, isn't that a forward slash? I don't know python but I think you may have got it backwards. Isn't this / a forward slash and this \ a back slash? Or am I just stupid/crazy? Please explain.
+ 3
You might be right. But even so, \ would only be used for escape characters, which is raw text; something that isn't until the very end of the Python course.
+ 2
Oh ok. Good job explaining, even if I don't know what you mean.
;)
+ 1
Thank you
+ 1
Backslashes are introduced in the first module of the course: Basic Concepts, section 6: Strings.
Floating AI like Google search can guess what you mean, and this thread may even have MBTI value...but binary computer Python's just going to do arbitrary things while you're slash-arbitrary.
http://xkcd.com/1220
My favorite part of that comic is the (hover-over-the-comic) alt-text. or the title text. Can't seem to remember the difference.
0
\ is for escape character.
For eg:
print('I am a \'good\' boy') will give you- I am a 'good' boy
/ is divide operator.
For eg: 4/2 is 2.0
For integer result use 4//2 which is 2