# What is the output of following Python code?

### 2. what is the output of following Python code?

s = 'clcoding'

print(s[1:6][1:3])

### Solution and Explanation:

Let's break down the expression s[1:6][1:3] step by step:

s[1:6]: This part of the expression extracts a substring from the original string s. The slice notation [1:6] indicates that we want to start from index 1 (inclusive) and end at index 6 (exclusive), effectively extracting characters from index 1 to index 5 (0-based indexing). So, after this step, the substring extracted is 'lcodi'.

[1:3]: This part further slices the substring obtained from the previous step. The slice notation [1:3] indicates that we want to start from index 1 (inclusive) and end at index 3 (exclusive) within the substring 'lcodi'. So, after this step, the substring extracted is 'co'.

Putting it all together, when you execute print(s[1:6][1:3]), it extracts a substring from the original string s starting from index 1 to index 5 ('lcodi'), and then from this substring, it further extracts a substring starting from index 1 to index 2 ('co'). Therefore, the output of the expression is:

co

print(0o12)

### Solution and Explanation:

The expression 0o12 is a way of representing an octal (base-8) number in Python. In Python, an octal number starts with 0o, followed by digits from 0 to 7. Let's break it down:

0o: This prefix indicates that the number following it is in octal notation.
12: In octal notation, 12 represents the number 1 multiplied by 8^1 plus 2 multiplied by 8^0, which equals 8 + 2, or simply 10 in base-10 notation.
So, when you print 0o12, it will display 10, which is the equivalent value in base-10 notation.