Python Forum
What will the following code output? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: What will the following code output? (/thread-14732.html)



What will the following code output? - dukoolsharma - Dec-14-2018

What output will the following code give?
>>> word=’abcdefghij’
>>> word[:3]+word[3:]



RE: What will the following code output? - buran - Dec-14-2018

What do you think? Did you try to run it if not able to say just from looking at it?


RE: What will the following code output? - Gribouillis - Dec-14-2018

It would have been faster and more efficient to type the same code in the python interpreter instead of the forum!


RE: What will the following code output? - ichabod801 - Dec-14-2018

The output is:

Output:
'this sounds like homework'



RE: What will the following code output? - jeanMichelBain - Dec-14-2018

If you are on linux, just enter on your keyboard :
python3
If you are on windows, download the last release on :
https://www.python.org/downloads/windows/
If you cannot install because you don' have administrative access... try to find some web site with a python terminal for free.
You can also buy a raspberrypi (arround 10$), but you will need also a screen and a keyboard (take them from the pc you used for the forum), and you will have to download and install raspbian.
If you fail with all of that, read the doc : https://docs.python.org/3/tutorial/index.html , your brain will give you the answer quickly.


RE: What will the following code output? - HarshaliPatel - Dec-15-2018

The output is ‘abcdefghij’. The first slice gives us ‘abc’, the next gives us ‘defghij’.