Friday, 10 November 2017

TCS aspire Python questions & Answers

1. What gets printed
foo = {}
print type(foo)
ANS: <class ‘dict’>
2. Type of error in ‘st’+1
ANS: Type error
3. Python supports regular expressions
ANS: True
4. Like the else, the elif statement is optional.
ANS: True
5. What gets printed?
numberGames={}
numberGames[(1,2,3)]=8
numberGames[(4,2,1)]=10
numberGames[(1,2)]=12 sum=0
for k in numberGames:
sum+=numberGames[k]
print len(numberGames)+sum
ANS: 33
6. The readlines() method returns
ANS: a list of lines
7. Suppose s is “\t\tWorld\n”, what is s.strip()?
ANS: World
8. Function can not have return statement
ANS: False
9. What is the difference between a class and an object in python?
ANS: Objects are created from class
10. Raw_input() returns
ANS: String
11. Output of following code
Si=’spamandeggs’
X=si.find(‘and’)
Print(x)
Print(si[0:1],si[5:7])
ANS: 4(‘s’,’nd’)
12. Which method is used to delete an object created by initializing constructor.
ANS: Destructor
13. To read two characters from a file object infile, we use
ANS: infile.read(2)
14. What would the statement “print('%.2f'%123.444)”
ANS: 123.44
15. What can you put before and after a section to make all of the lines a comment?
ANS: ‘’’
16. What gets printed ?
nums=set([1,1,2,3,3,3,4])
Print len(nums)
ANS: 4
17. Python programming can handle every error implicitly
ANS: True
18. Syntax error is also called as
ANS: parsing error
19. Str1=’hello’
Str2=’,’
Str3=’world’
Str1[-1:]
ANS: o
20. Str1=’helloworld’
Str1[::-1]
ANS: dlrowolleh
21. 2.0+2
ANS: 4.0
22. E=’hello’ print E.find(‘e’)
ANS: 1
23. What arithmetic operator can not be used with strings?
ANS: **,-
24. Foo={1:’1’,2:’2’,3:’3’}
Foo={}
Print len(Foo)
ANS: 0
25. Print ‘new’’line’
ANS: newline
26. Python is not suited for fast and memory intensive tasks
ANS: True
27. Enthought or rather EPD
ANS: Integrated development environment for python
28. Which of the following are immutable built-in types of python
ANS: numbers,strings,tuples
29. The format function returns:
ANS: str
30. How much control statements python supports?
ANS: 3
31. Print “abcd”[2:]
ANS: cd
32. def myfunc(x,y,z,a):
print x+y
nums=[1,2,3,4]
myfunc(*nums)
ANS: 3
33. example="snow world"
print "%s"%example[4:7]
ANS: wo
34. print str(1)+str(2)
ANS: 12
35. IndentError is not python built-in exception
36. Use of sys.stdout.flush() is
ANS: get that text on the screen quickly.
37. names=['Amir','Barry','Chales','Dao']
print names[-1][-1]
ANS:o
38. Suppose i is 5 and j is 4, i + j is same as
ANS: i.__add__(j)

20 comments:

  1. This information you provided in the blog that is really unique I love it!! Thanks for sharing such a great blog. Keep posting..
    Python training
    Python Course
    Python training institute

    ReplyDelete
  2. thanks for sharing such an amazing information... Keep posting

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. Superb. I really enjoyed very much with this article here. Really it is an amazing article I had ever read. I hope it will help a lot for all.
    Python Training
    Python course

    ReplyDelete
  5. Such an interesting and informative piece of guidance imparted by you. I am glad to discover this information here and I am sure that this might be beneficial for us.
    Web delopment company in India

    ReplyDelete
  6. Nice blog Content.It is very informative and helpful. Please share more content. Thanks.
    Vmware Training in Gurgaon
    Vmware Course in Gurgaon
    Vmware Training institute in Gurgaon

    ReplyDelete
  7. Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging
    Python Training in electronic city

    ReplyDelete
  8. Good Post. I like your blog. Thanks for Sharing..................!
    Python Course in Noida

    ReplyDelete
  9. This is information is better good luckpython course

    ReplyDelete
  10. Ensure you are registered for this course and enjoy the advantages of the Machine Learning Training in Hyderabad at AI Patasala.
    Online Machine Learning Training in Hyderabad

    ReplyDelete
  11. Sign up today for the intensive Python Course in Hyderabad program taught by experienced trainers from AI Patasala.
    Python Course Hyderabad

    ReplyDelete
  12. This comment has been removed by the author.

    ReplyDelete
  13. Wonderful post. Connect with us for Python Training

    ReplyDelete