0% found this document useful (0 votes)
4 views1 page

Python Basics: Solutions & Explanations

Uploaded by

Natasha poojary
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

Python Basics: Solutions & Explanations

Uploaded by

Natasha poojary
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Python Basics - Solutions & Explanations

1. <class 'int'>

Explanation: The type() function shows the type of variable 'x', which is an integer.

2. 3.5 is a float.

Explanation: str(x) converts the float into a string for concatenation.

3. y

Explanation: Index 1 in 'Python' is the letter 'y' (indexing starts at 0).

4. No error.

Explanation: str(b) changes the integer into a string, so string concatenation works.

5. lic

Explanation: The slice [1:4] takes characters at index 1, 2, and 3.

6. 6

Explanation: 4 + 2 = 6, and the value of a is updated.

7. <class 'float'>

Explanation: 2.0 is a float, so type(x) returns 'float'.

8. 510

Explanation: These are strings, so + joins them together.

9. 3.5

Explanation: Division operator '/' returns a float result.

10. 15 is a number

Explanation: x becomes '15' after str(x), and then it is concatenated with the string.

You might also like