Question

I need help writing a code to solve this problem.

(1) (20pts) Write programs in Python or C++ to to solve the following problem: Steve, John and Luke make their living as carp

The question asks "What position does each man fill? Submit a listing(code), and the output of your program"

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Hello, the answer to the below question is as follows:

#Workers we have is : steve, john and luke
#S-steve; J-John; l-Luke
worker=['S','J','L']
#positions which are available for each man
#A-painter; B-Plumber; C-Carpenter
position=['A','B','C']
#since painter had a talk with carpenter regarding some work so they heard of each other
#since carpenter was doing remodelling of plumber so they also heard of each other
possible_heard=[('C','A'),('C','B'),('A','B')]
heard=[('C','A'),('C','B')]
not_heard=[]

for i in possible_heard:
    if i not in heard:
        not_heard.append(i)
#print(
#since john has never heard of luke
#not_heard must have their set
worker_never_heard=[('J','L')]
#d-dictionary having result sets
d={}
for i in worker:
    if i in worker_never_heard[0]:
        d[i]=list(not_heard[0])
    else:
        x=[]
        for j in position:
            if j not in not_heard[0]:
                x.append(j)
            d[i]=x
          
#since Its is give that plumber makes more money than painter
money_comp=[('B',1),('A',0)]
#Luke makes more money than John
max_index=0
for i in money_comp:
    if i[1]>0:
        max_index=money_comp.index(i)
else:
    x=1
d['L']=list(money_comp[max_index][0])
d['J']=list(money_comp[x][0])
print(d)
print("Abbreviation---> S-steve; J-John; l-Luke")
for i,j in d.items():
    if j[0]=='A':
        print(i,": Painter")
    elif j[0]=='B':
        print(i,": Plumber")
    elif j[0]=='C':
        print(i,": Carpenter")

and the output is:

$python main.py
{'S': ['C'], 'J': ['A'], 'L': ['B']}
Abbreviation---> S-steve; J-John; l-Luke
('S', ': Carpenter')
('J', ': Painter')
('L', ': Plumber')

comment for any query
thanks

Add a comment
Know the answer?
Add Answer to:
I need help writing a code to solve this problem. The question asks "What position does...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I need help please. I can solve this problem Question 50 6 pts Surgery Study: Part...

    I need help please. I can solve this problem Question 50 6 pts Surgery Study: Part One: Advocates of minimally invasive surgery (MIS) claim that patients experience more pain with traditional surgery which makes larger incisions than they do with MIS. To investigate this claim, a researcher collected data on patients who underwent cardiovascular surgery, half with traditional surgery and half with MIS. The data consisted of the reported pain level of each patient recorded 24 hours after surgery. The...

  • Hello dear, Please i need help to solve this problem in Finance 1. Apply What You’ve...

    Hello dear, Please i need help to solve this problem in Finance 1. Apply What You’ve Learned - Auto Purchase Scenario: You are in the market for a new car. You do not have a trade-in, but you have saved $2,500 toward a down payment. You currently earn $4,000.00 gross monthly income, of which 35% is withheld for various deductions. You have heard of the 20% rule of thumb, but want to limit your payments to no more than 15%...

  • Hey guys I need help with this assignment. However it contains 7 sub-problems to solve but I figured only 4 of them can...

    Hey guys I need help with this assignment. However it contains 7 sub-problems to solve but I figured only 4 of them can be solved in one post so I posted the other on another question so please check them out as well :) Here is the questions in this assignment: Note: Two helper functions Some of the testing codes for the functions in this assignment makes use of the print_dict in_key_order (a dict) function which prints dictionary keyvalue pairs...

  • i tried to solve this question but its too hard for me, can i pls get some help? Hi! i think this question is super hard and i cant understand it, it goes like this A goldsmith has a bracelet that...

    i tried to solve this question but its too hard for me, can i pls get some help? Hi! i think this question is super hard and i cant understand it, it goes like this A goldsmith has a bracelet that weighs 20 grams. Of the weight of the bracelet 60% is gold and 40% silver. a) How many grams of silver does the bracelet contain? The goldsmith will now make a new bracelet with a halved portion of silver,...

  • I need a python 3 help. Please help me with this question Part 2. Linked Lists...

    I need a python 3 help. Please help me with this question Part 2. Linked Lists You start working with the class LinkNode that represents a single node of a linked list. It has two instance attributes: value and next. class LinkNode: def __init__(self,value,nxt=None): assert isinstance(nxt, LinkNode) or nxt is None self.value = value self.next = nxt Before you start with the coding questions, answer the following questions about the constructor Valid Constructor or Not? LinkNode(1, 3) LinkNode(1, None) LinkNode(1,...

  • i really need help with the graphs Driving Can Be Dangerous to Your Health: An Interrupted...

    i really need help with the graphs Driving Can Be Dangerous to Your Health: An Interrupted Case Study in Physiology Phil Stephens Department of Biology Villanova University Part 1-The Grandparents Arrive Dave pulled the cell phone out of his pocket, cursing himself for not putting it on vibrate. The children, Jason and Laura, were both asleep, and he knew that the rest of the day would not be fun if they were awakened from their naps. "Hi, Dave. We're just...

  • i have the case study question with the answers but i need help to re-write the...

    i have the case study question with the answers but i need help to re-write the answers. please see the attached files Case Study Analysis (CSF3003) Assessment Description and Requirements CLO1: Case Study 1 Ahmad lef home to study master and PhD in Australia. He has fees for the first semester only. After he arrived to Sydney and settled down, he start looking for a part-time job to save money for the next term. Ahmad has some experience on making...

  • please answer this question. i hace also attacehd the article images. I just cant answer it...

    please answer this question. i hace also attacehd the article images. I just cant answer it my mother is in the hospital. Listen to the story about selling dinosaur bones on ebay. Print this page, write up your answers (handwritten please), can and post at a PDF document (jpeg so long as it is legible) 1) (8 pts) Using the graph below, demonstrate what happened to the market for dinosaur bones as more fossil hunters enter the fossil market? Indicate...

  • Hi there! I need to compare two essay into 1 essay, and make it interesting and...

    Hi there! I need to compare two essay into 1 essay, and make it interesting and choose couple topics which im going to talk about in my essay FIRST ESSAY “Teaching New Worlds/New Words” bell hooks Like desire, language disrupts, refuses to be contained within boundaries. It speaks itself against our will, in words and thoughts that intrude, even violate the most private spaces of mind and body. It was in my first year of college that I read Adrienne...

  • I need Summary of this Paper i dont need long summary i need What methodology they used , what is the purpose of this p...

    I need Summary of this Paper i dont need long summary i need What methodology they used , what is the purpose of this paper and some conclusions and contributes of this paper. I need this for my Finishing Project so i need this ASAP please ( IN 1-2-3 HOURS PLEASE !!!) Budgetary Policy and Economic Growth Errol D'Souza The share of capital expenditures in government expenditures has been slipping and the tax reforms have not yet improved the income...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT