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
  problem in output of a snippet code akbarza 2 302 Feb-28-2024, 07:15 PM
Last Post: deanhystad
  I cannot able to see output of this code ted 1 716 Feb-22-2023, 09:43 PM
Last Post: deanhystad
  why I dont get any output from this code William369 2 1,084 Jun-23-2022, 09:18 PM
Last Post: William369
  How can I organize my code according to output that I want ilknurg 1 1,141 Mar-11-2022, 09:24 AM
Last Post: perfringo
  Why this code not getting desired output ? MDRI 2 2,486 Sep-18-2020, 02:11 AM
Last Post: MDRI
  I couldn't understand the output of the below code ravich129 1 1,893 Dec-12-2019, 06:24 AM
Last Post: sandeep_ganga
  Output of Python code hemal07yc 5 3,880 Sep-13-2019, 11:33 AM
Last Post: perfringo
  Output not following rules set in code. Escribblings 4 3,060 Apr-24-2019, 12:49 PM
Last Post: Escribblings
  No output for the code to read emails avani9659 6 4,151 Aug-14-2018, 08:30 AM
Last Post: avani9659
  i need assistance on the output of a particular code sirvinprogramming 3 3,264 May-19-2018, 03:37 PM
Last Post: buran

Forum Jump:

User Panel Messages

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