I don't understand back slashes please help | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

I don't understand back slashes please help

15th Nov 2016, 2:56 AM
ExoticButters
ExoticButters - avatar
7 Answers
+ 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.
15th Nov 2016, 3:02 AM
Keto Z
Keto Z - avatar
+ 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.
15th Nov 2016, 3:54 AM
Code Purple
Code Purple - avatar
+ 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.
15th Nov 2016, 3:55 AM
Keto Z
Keto Z - avatar
+ 2
Oh ok. Good job explaining, even if I don't know what you mean. ;)
15th Nov 2016, 3:58 AM
Code Purple
Code Purple - avatar
+ 1
Thank you
15th Nov 2016, 3:28 AM
ExoticButters
ExoticButters - avatar
+ 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.
15th Nov 2016, 9:04 AM
Kirk Schafer
Kirk Schafer - avatar
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
28th Nov 2016, 11:34 AM
Austin Joyal
Austin Joyal - avatar