Logo F2FInterview

Python Interview Questions

Q   |   QA

This will print the word 'abcdefghij'

word = 'word'
print word.__len__()

try:
  f1=open("filename.txt","r")
except Exception, e:
  print "%s" %e

print f1.readlines()

a = 1
a,b=a+1,a+1
print a
print b

2
2

Here in the second line a,b=a+1,a+1 means that a=a+1 and b=a+1 which is 2. But this is the python way of initialization which a python programmer should understand.

words = ['one', 'one', 'two', 'three', 'three', 'two']

In order to link this F2FInterview's page as Reference on your website or Blog, click on below text area and pres (CTRL-C) to copy the code in clipboard or right click then copy the following lines after that paste into your website or Blog.

Get Reference Link To This Page: (copy below code by (CTRL-C) and paste into your website or Blog)
HTML Rendering of above code: