Python Interview Questions
- 0of 0 votes
AnswersA Courier running firm want to automate the job of “service coverage area” based on the pin code of the AREA and it should display the message as mentioned below If service is available then display the statement: Service available for the locality: Area Name Otherwise display the statement: No Service available for the locality: Pincode Develop a Python program for the implementation of the above scenario?
- D PRAVEEN KUMAR January 18, 2018 in United States| Report Duplicate | Flag | PURGE
TCS CodeVita Python - 0of 0 votes
AnswersImplement an Object oriented programming features like Class, Object, Constructor in Python to capture basic details of an Employee like Name, Salary etc. Develop a program to read and display the Employee details along with the total number of employees exists , currently? Hint: i. Make use of Class concept, Object creation and accessing objects using the member functions ii. Make use of constructor to initialize the employee details / employee object\ iii. Create get functions (one for each attribute / property) to display employee details and employee count.
- D PRAVEEN KUMAR January 18, 2018 in United States| Report Duplicate | Flag | PURGE
TCS CodeVita Python - 0of 0 votes
AnswersA store provides the facility for customer and sales person/manager to view all the products in the alphabetical order of the Products. Which makes tracking easy. Develop a Python program to automate the above task?
- D PRAVEEN KUMAR January 18, 2018 in United States| Report Duplicate | Flag | PURGE
TCS CodeVita Python - 0of 0 votes
AnswersA Gaming institute want to assign grade / score for each student based on the game results in Finals. So develop an application using Python which will automates to display the list of students, who falls into the below categories in Finals and which will helps the management to provide the scores accordingly? Categories: -Who is a loser at least in one game? -Who is a looser in all the games? Note: i. Consider that, same Associate might be the looser in more than one game ii. There are three games conducted: Chess, Caroms, Long jump ii. Develop a program in such a way that , it works on only on Finalists in each game Hint: i. Use the data structures: List / Dictionary along with the set data structure. ii. Maintain a separate list / dictionary for each game finalists and store couple of students in the list and use these lists for finding out the students, who falls into the above category mentioned in the problem statement For Ex: chessFinalList=['Hanu','Raja','RAMA'] caromsFinalList=['RAJA', 'RAMA','RAMANA'] longJumpFinalList=['RAJA','RAMA','RAVI']
- D PRAVEEN KUMAR January 18, 2018 in India| Report Duplicate | Flag | PURGE
TCS CodeVita Python - 0of 0 votes
AnswersA smart-set is a set of distinct numbers in which all the elements have the same number of 1s in their binary form. The set of all smallest elements from each smart-set
- aspi December 15, 2017 in United States
that can be formed from a given array of distinct positive numbers is known as the smartest-set.
So given an array of distinct numbers, outline the elements of the smartest-set in ascending sorted order.
Input Format
The first line of input consists of an integer t. This is the number of test cases. For each test case,
the first line of input contains an integer n. Here n is the number of elements in the array. The next line contains n space separated distinct integers which are the elements
of the array.
Output Format
The output will space separated integer elements of the smartest-set in ascending order.
Constraints
0 < t < 1000 (This is the number of test cases
2 < n < 10000 (This is the number of integer elements of the array)
1 < Xi < 100000 (This is the size of each element of the array)
Python coding| Report Duplicate | Flag | PURGE
Python - 1of 1 vote
Answers## This is the text editor interface.
- wonderkid September 02, 2017 in United States
## Anything you type or change here will be seen by the other person in real time.
# Implement the function that takes a board string
# and decodes it into the representative 2D array.
#
# |_|_|_|_|_|_|_|
# |_|_|r|_|_|_|_|
# |b|r|b|r|b|r|_|
# |b|b|b|r|r|b|_|
# |b|r|r|b|b|r|_|
# |r|b|b|r|r|r|b|
# CFN: 9_r4_brbrbr_3b2rb_b2r2br_r2b3rb
#
# This function should return a list of lists of strings.
# (i.e. a string[6][7]). The strings should be one of:
# * 'r' to indicate a red piece
# * 'b' to indicate a black piece
# * '_' to indicate an empty space
#
# The input string is not necessarily a valid
# CFN board string. It is guaranteed not-empty.| Report Duplicate | Flag | PURGE
Palantir Technology Software Engineer Python - 0of 0 votes
AnswersGiven an array with +ve and -ve integer, find the maximum sum such that you are not allowed to skip 2 contiguous elements ( i.e you have to select at least one of them to move forward).
- Smart August 25, 2017 in United States
Test Cases:
10 , 20 , 30, -10 , -50 , 40 , -50, -1, -3
Output : 10+20+30-10+40-1 = 89
-1,-2,-3,-4,-5
Output: -2-4=-6| Report Duplicate | Flag | PURGE
Student freshers Python - 0of 0 votes
Answersnumber_one = "193283492420348904832902348908239048823480823"
- shopatlemo July 01, 2017 in United States
number_two = "3248234890238902348823940990234"
Question:
1) I need to multiply this and get the answer
2) DO NOT CONVERT TO INT AND DO THE MULTIPLICATION| Report Duplicate | Flag | PURGE
Facebook Data Engineer Python - 3of 3 votes
Answershow to sort a list with dictionary as variables.Sort should be based on dictionary value.
for example :a = [{'b':2},{'b':1},{'b':5}{'b':4]
now the sort should be based on value.
- rkcchaitu June 02, 2017 in India| Report Duplicate | Flag | PURGE
Software Engineer in Test Python - 1of 1 vote
AnswersProgramming Challenge Description:
- abhinav.thegame October 17, 2016 in United States
Develop a service to help a client quickly find a manager who can resolve the conflict between two employees. When there is a conflict between two employees, the closest common manager should help resolve the conflict. The developers plan to test the service by providing an example reporting hierarchy to enable the identification of the closest common manager for two employees. Your goal is to develop an algorithm for IBM to efficiently perform this task. To keep things simple, they just use a single relationship "isManagerOf" between any two employees. For example, consider a reporting structure represented as a set of triples:
Tom isManagerOf Mary
Mary isManagerOf Bob
Mary isManagerOf Sam
Bob isManagerOf John
Sam isManagerOf Pete
Sam isManagerOf Katie
The manager who should resolve the conflict between Bob and Mary is Tom(Mary's manager). The manager who should resolve the conflict between Pete and Katie is Sam(both employees' manager). The manager who should resolve the conflict between Bob and Pete is Mary(Bob's manager and Pete's manager's manager).
Assumptions:
There will be at least one isManagerOf relationship.
There can be a maximum of 15 team member to a single manager
No cross management would exist i.e., a person can have only one manager
There can be a maximum of 100 levels of manager relationships in the corporation
Input:
R1,R2,R3,R4...Rn,Person1,Person2 R1...Rn - A comma separated list of "isManagerOf" relationships. Each relationship being represented by an arrow "Manager->Person". Person1,Person2 - The name of the two employee that have conflict
Output:
The name of the manager who can resolve the conflict Note: Please be prepared to provide a video follow-up response to describe your approach to this exercise.
Test 1:
Test Input
Frank->Mary,Mary->Sam,Mary->Bob,Sam->Katie,Sam->Pete,Bob->John,Bob,Katie
Expected Output
Mary
Test 2:
Test Input
Sam->Pete,Pete->Nancy,Sam->Katie,Mary->Bob,Frank->Mary,Mary->Sam,Bob->John,Sam,John
Expected Output
Mary| Report Duplicate | Flag | PURGE
IBM Software Engineer / Developer Coding Java Python String Manipulation - 0of 0 votes
AnswerI
- shaina.verma26 September 28, 2016 in United States for IOT| Report Duplicate | Flag | PURGE
MAGMA abc Python - 0of 0 votes
AnswersWrite a Python program to print numbers from 1 to 100 except for multiples of 3 for which you should print "fuzz" instead, for multiples of 5 you should print 'buzz' instead and for multiples of both 3 and 5, you should print 'fuzzbuzz' instead.
- NS March 03, 2016 in United States| Report Duplicate | Flag | PURGE
JP Morgan Software Engineer / Developer Python - 0of 0 votes
AnswersImplement a function DoIt( o,a ) such that the following code:
Object o = SomeClass() O.first = 'fizz' O.second = 'buzz' print DoIt( o, 'first) print DoIt(o, 'second')
prints
- NS March 03, 2016 in United States
fizz
buzz| Report Duplicate | Flag | PURGE
JP Morgan Software Engineer / Developer Python - 0of 0 votes
AnswersWrite a iterative Python function to print the factorial of a number n (ie, returns n!).
- NS March 03, 2016 in United States| Report Duplicate | Flag | PURGE
JP Morgan Software Engineer / Developer Python - 0of 0 votes
AnswersWrite a recursive Python function to print the factorial of a number n (ie, returns n!).
- NS March 03, 2016 in United States| Report Duplicate | Flag | PURGE
JP Morgan Software Engineer / Developer Python - 2of 2 votes
AnswersYou have a function rand5(). This function returns numbers between 1 and 5 randomly with equal probability. Implement a function rand7() which makes use of rand5 to return a number between 1 and 7 randomly with equal probability.
- reddygokul.i7 February 27, 2015 in India| Report Duplicate | Flag | PURGE
Intern Algorithm Arrays Java Python - 0of 0 votes
AnswersThe SHIELD is a secretive organization entrusted with the task of guarding the world against any disaster. Their arch nemesis is the organization called HYDRA. Unfortunately some members from HYDRA had infiltrated into the SHIELD camp. SHIELD needed to find out all these infiltrators to ensure that it was not compromised.
- reddygokul.i7 February 26, 2015 in India
Nick Fury, the executive director and the prime SHIELD member figured out that every one in SHIELD could send a SOS signal to every other SHIELD member he knew well. The HYDRA members could send bogus SOS messages to others to confuse others, but they could never receive a SOS message from a SHIELD member. Every SHIELD member would receive a SOS message ateast one other SHIELD member, who in turn would have received from another SHIELD member and so on till NickFury. SHIELD had a sophisticated mechanism to capture who sent a SOS signal to whom. Given this information, Nick needed someone to write a program that could look into this data and figure out all HYDRA members.
Sample Input
Nick Fury : Tony Stark, Maria Hill, Norman Osborn
Hulk : Tony Stark, HawkEye, Rogers
Rogers : Thor,
Tony Stark: Pepper Potts, Nick Fury
Agent 13 : Agent-X, Nick Fury, Hitler
Thor: HawkEye, BlackWidow
BlackWidow:Hawkeye
Maria Hill : Hulk, Rogers, Nick Fury
Agent-X : Agent 13, Rogers
Norman Osborn: Tony Stark, Thor
Sample Output
Agent 13, Agent-X, Hitler
You can code in any language of your choice. Input and Output must be in the same format as above| Report Duplicate | Flag | PURGE
xyz Algorithm C++ Java Python - 1of 1 vote
AnswersGiven a list of employees and their bosses as a text file , write a function that will print out a hierarchy tree of the employees.
- shalini.ravishankar February 08, 2015 in United States
Sample input =
Sam, Ian, technical lead, 2009 / Ian, NULL, CEO,2007/ Fred, Sam, developer, 2010
The format is name, supervisor, designation, year of joining
The output should be
Ian CEO 2007
-Sam Technical lead 2009
- -Fred Developer 2010| Report Duplicate | Flag | PURGE
Student Algorithm Coding Python - 0of 2 votes
AnswersInput : A Perl program file
- Seeker September 25, 2013 in United States
We need to modify the file to have a max of 80 characters per line and create a new perl file.
Problem is we need to use "/" wherever we split the line and also, the split MUST happen at a place with white space. (ASSUMPTION - No is >75 characters)| Report Duplicate | Flag | PURGE
Google Developer Program Engineer Algorithm Perl Python - 0of 0 votes
AnswersDesign a web crawler to dump all the pages of a given website (URL) onto disk. So basically it saves pages which is related to the website (for instance dump all pages of aws.amazon.com) and do not crawl the links outside the website
- vik September 06, 2013 in United States
I coded it in python and then they asked what is the internal structure of dict in python and why or why not it is fast| Report Duplicate | Flag | PURGE
Amazon Software Engineer Intern Coding Data Structures Python - 1of 1 vote
AnswersGot FB interview questions is not difficult, basically, he is asking to count number of identical chars in a given string with with some special case handling, and return the number with highest count, question is pretty long leaving you to dig an algorithm.
Etc, given string "coffee tuffee", should return 4.
I was having my usual interview brain freeze, and start doing initializing with int, how silly
well after interview when I cool down, it doesn't take long to figure out as code below, little over weighted algorithm but the most concise I can wrote, someone please give more efficient code.
- mailming December 08, 2012 in United Statesdef parseword(a_word): a_word=a_word.lower() count=list(map(a_word.count, a_word)) return (max(count))
| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Python - 2of 2 votes
AnswersMcDonald’s sells Chicken McNuggets in packages of 6, 9 or 20 McNuggets. Thus, it is possible, for example, to buy exactly 15 McNuggets (with one package of 6 and a second package of 9), but it is not possible to buy exactly 16 McNuggets, since no non- negative integer combination of 6's, 9's and 20's add up to 16. To determine if it is possible to buy exactly n McNuggets, one has to find non-negative integer values of a, b, and c such that
- nishakothari62 November 03, 2012 in United States
6a+9b+20c=n
Write a function, called McNuggets that takes one argument, n, and returns True if it is possible to buy a combination of 6, 9 and 20 pack units such that the total number of McNuggets equals n, and otherwise returns False. Hint: use a guess and check approach.| Report Duplicate | Flag | PURGE
Facebook Developer Program Engineer Python - 1of 1 vote
AnswersWrite a recursive procedure, called laceStringsRecur(s1, s2), which also laces together two strings. Your procedure should not use any explicit loop mechanism, such as a for or while loop. We have provided a template of the code; your job is to insert a single line of code in each of the indicated places.
- nishakothari62 November 03, 2012 in United Statesdef laceStringsRecur(s1, s2): """ s1 and s2 are strings. Returns a new str with elements of s1 and s2 interlaced, beginning with s1. If strings are not of same length, then the extra elements should appear at the end. """ def helpLaceStrings(s1, s2, out): if s1 == '': #PLACE A LINE OF CODE HERE if s2 == '': #PLACE A LINE OF CODE HERE else: #PLACE A LINE OF CODE HERE return helpLaceStrings(s1, s2, '')
| Report Duplicate | Flag | PURGE
Facebook Developer Program Engineer Python - 0of 0 votes
AnswersWhat is the return value of __init__(self): operator? Is there any default __init__ in a class? Can we call __init__()?(anyhow)
- Anonymous April 09, 2010| Report Duplicate | Flag | PURGE
Python