• +91 9723535972
  • info@interviewmaterial.com

PYTHON Interview Questions and Answers

Related Subjects

PYTHON Interview Questions and Answers

Question - 21 : - What is the output of print list[2:] if list = [ 'abcd', 786 , 2.23, 'john', 70.2 ]?

Answer - 21 : - It will print elements starting from 3rd element. Output would be [2.23, 'john', 70.200000000000003].

Question - 22 : - What is the output of print tinylist * 2 if tinylist = [123, 'john']?

Answer - 22 : - It will print list two times. Output would be [123, 'john', 123, 'john'].

Question - 23 : - What is the output of print list + tinylist * 2 if list = [ 'abcd', 786 , 2.23, 'john', 70.2 ] and tinylist = [123, 'john']?

Answer - 23 : - It will print concatenated lists. Output would be ['abcd', 786, 2.23, 'john', 70.200000000000003, 123, 'john'].

Question - 24 : - What are tuples in Python?

Answer - 24 : - A tuple is another sequence data type that is similar to the list. A tuple consists of a number of values separated by commas. Unlike lists, however, tuples are enclosed within parentheses.

Question - 25 : - What is the difference between tuples and lists in Python?

Answer - 25 : - The main differences between lists and tuples are − Lists are enclosed in brackets ( [ ] ) and their elements and size can be changed, while tuples are enclosed in parentheses ( ( ) ) and cannot be updated. Tuples can be thought of as read-only lists.

Question - 26 : - What is the output of print tuple if tuple = ( 'abcd', 786 , 2.23, 'john', 70.2 )?

Answer - 26 : - It will print complete tuple. Output would be ('abcd', 786, 2.23, 'john', 70.200000000000003).

Question - 27 : - What is the output of print tuple[0] if tuple = ( 'abcd', 786 , 2.23, 'john', 70.2 )?

Answer - 27 : - It will print first element of the tuple. Output would be abcd.

Question - 28 : - What is the output of print tuple[1:3] if tuple = ( 'abcd', 786 , 2.23, 'john', 70.2 )?

Answer - 28 : - It will print elements starting from 2nd till 3rd. Output would be (786, 2.23).

Question - 29 : - What is the output of print tuple[2:] if tuple = ( 'abcd', 786 , 2.23, 'john', 70.2 )?

Answer - 29 : - It will print elements starting from 3rd element. Output would be (2.23, 'john', 70.200000000000003).

Question - 30 : - What is the output of print tinytuple * 2 if tinytuple = (123, 'john')?

Answer - 30 : - It will print tuple two times. Output would be (123, 'john', 123, 'john').


NCERT Solutions

 

Share your email for latest updates

Name:
Email:

Our partners