Python Forum
What will the following code output?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
What will the following code output?
#1
What output will the following code give?
>>> word=’abcdefghij’
>>> word[:3]+word[3:]
Reply
#2
What do you think? Did you try to run it if not able to say just from looking at it?
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
It would have been faster and more efficient to type the same code in the python interpreter instead of the forum!
Reply
#4
The output is:

Output:
'this sounds like homework'
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#5
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.
Reply
#6
The output is ‘abcdefghij’. The first slice gives us ‘abc’, the next gives us ‘defghij’.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Why this code not getting desired output ? MDRI 2 1,304 Sep-18-2020, 02:11 AM
Last Post: MDRI
  I couldn't understand the output of the below code ravich129 1 889 Dec-12-2019, 06:24 AM
Last Post: sandeep_ganga
  Output of Python code hemal07yc 5 1,925 Sep-13-2019, 11:33 AM
Last Post: perfringo
  Output not following rules set in code. Escribblings 4 1,556 Apr-24-2019, 12:49 PM
Last Post: Escribblings
  No output for the code to read emails avani9659 6 2,275 Aug-14-2018, 08:30 AM
Last Post: avani9659
  i need assistance on the output of a particular code sirvinprogramming 3 1,985 May-19-2018, 03:37 PM
Last Post: buran
  Unable to get my code to output fadi 3 2,117 Feb-07-2018, 03:36 AM
Last Post: Larz60+
  csv output code migs2173 2 2,282 Jul-08-2017, 10:06 AM
Last Post: migs2173

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020