1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
stiks02 [169]
3 years ago
7

Write a program that asks for the names of three runners and the time, in minutes (no seconds, etc.), it took each of them to fi

nish a race. The program should display the names of the runners in the order that they finished. Note, assume there are no ties.

Computers and Technology
1 answer:
Crank3 years ago
5 0

Answer:

Complete python code with explanation and output results is given below

Explanation:

User is asked to input names of runners and their finishing time

We have to determine first, second and third according to their finishing time.

if else conditioning is used to determine who has lowest finishing time.

Outer if is used to decide first position and inner if is used to decide second and third position.

str() function is used to concatenate the integer variable with string

Code:

runner1 = input("Please enter name of the runner1 ")

time1 = int(input("Please enter the time of runner1 "))

runner2 = input("Please enter name of the runner2 ")

time2 =int(input("Please Enter name of the runner2 "))

runner3 = input("Please enter name of the runner3 ")

time3 =int(input("Please Enter name of the runner3 "))

if(time1 < time2 and time1 < time3):  

   if(time2 < time3): // to decide 2nd and 3rd position

       print(runner1+" has finished First with time: "+str(time1))

       print(runner2+" has finished Second with time: "+str(time2))

       print(runner3+" has finished Third with time: "+str(time3))

   else:

       print(runner1+" has finished First with time: "+str(time1))

       print(runner3+" has finished Second with time: "+str(time3))

       print(runner2+" has finished Third with time: "+str(time2))

if(time2 < time1 and time2 < time3):  

   if(time1 < time3):

       print(runner2+" has finished First with time: "+str(time2))

       print(runner1+" has finished Second with time: "+str(time1))

       print(runner3+" has finished Third with time: "+str(time3))

   else:

       print(runner2+" has finished First with time: "+str(time2))

       print(runner3+" has finished Second with time: "+str(time3))

       print(runner1+" has finished Third with time: "+str(time1))

if(time3 < time1 and time3 < time2):

   if(time2 < time1):    

       print(runner3+" has finished First with time: "+str(time3))

       print(runner2+" has finished Second with time: "+str(time2))

       print(runner1+" has finished Third with time: "+str(time1))

   else:

       print(runner3+" has finished First with time: "+str(time3))

       print(runner1+" has finished Second with time: "+str(time1))

       print(runner2+" has finished Third with time: "+str(time2))

Output:

Program has been tested with multiple inputs and results are accurate as per problem specifications.

Please enter name of the runner1 danny

Please enter the time of runner1  45

Please enter name of the runner2  sam

Please enter the time of runner2  34

Please Enter name of the runner3  tedd

Please enter the time of runner3  23

tedd has finished First with time: 23

sam has finished Second with time: 34

danny has finished Third with time: 45

You might be interested in
What is the most common way to perform searches in a search engine?
valina [46]
Using key words is the best way to search things in the search engine. make sure everything is spelled correctly.
5 0
3 years ago
When the _____ logical operator is used to combine keywords, a search engine will retrieve all results containing either keyword
DanielleElmas [232]
OR! Because one OR the other (or both, as this is not an exclusive or) needs to be present in the search result.
8 0
3 years ago
Read 2 more answers
An automotive engine’s camshaft rotates?
ryzh [129]
<span>C. The same speed as the crankshaft..... hope this helps!
</span>
8 0
3 years ago
What dose a compress pictures command do ?
Nataliya [291]

Answer: I reduces the size

Explanation: cropped areas of pictures are saved by default, which adds to the file size. If your using PowerPoint then it can reduce the file size by compressing pictures, like lowering their resolution, and deleting cropped areas.

3 0
2 years ago
Write an awk script that produces a report from an input file. The report summarizes sales data as recorded for sales stations.
Hatshy [7]

Answer:

Script is given below

Explanation:

Below is the AWK code for the Report.I have used the sample data that your have shared in the question.

AWK code-

echo "Hello World!"

echo "2011 Jan X 29.44 17.33 43.21" > inputfile.txt

echo "2014 Jan Y 32.32 12.12 99.00 1.99 " >> inputfile.txt

echo "2012 Jan X 321.11 12.34 10.99" >> inputfile.txt

echo "2012 Feb Y 1.99 12.75" >> inputfile.txt

echo "2012 Feb X 32.99 65.78 98.76" >> inputfile.txt

echo "2014 Jan Y 12.99 17.44 21.34" >> inputfile.txt

echo "2012 Mar X 11.45" >> inputfile.txt

awk -F" " 'BEGIN{ X_sum=0;

print(" Sales Data for year 2014")

print("========================")

}

{ if($1=="2014")

{

print($2,":", $4+$5+$6+$7+$8+$9+$10+$11+$12+$13)

}

if($3=="X")

{

X_sum=X_sum+$4+$5+$6+$7+$8+$9+$10+$11+$12+$13

}

if($3=="Y")

{

Y_sum=Y_sum+$4+$5+$6+$7+$8+$9+$10+$11+$12+$13

}

if($3=="Z")

{

Z_sum=Z_sum+$4+$5+$6+$7+$8+$9+$10+$11+$12+$13

}

 

}

END { print(" ========================")

print("Station volume for 2014 is:")

print("X:" ,X_sum )

print("Y:" ,Y_sum )

print("Z:" ,Z_sum )

}

' < inputfile.txt

8 0
3 years ago
Other questions:
  • What effects will the different types of lighting produce on mountains?
    15·1 answer
  • IPv6 can use a DHCPv6 server for the allocation of IPv6 addressing to hosts. Another IPv6 addressing option utilizes the IPv6 Ne
    10·1 answer
  • What is the time period of 1st generation of computer ???
    11·1 answer
  • Which of the following is NOT an option in the comments group
    12·1 answer
  • How long did it take Linkedln to reach 1 million users?
    5·2 answers
  • On other questions, how do I write my own question, without commenting on others questions? It is only allowed two, I think, the
    13·1 answer
  • The person in charge of recording the sound should always
    15·1 answer
  • What kind of operating system is MS-DOS?
    8·2 answers
  • A college student needs a laptop that can be used while committing on the train and sitting in a lecture
    13·1 answer
  • Select the correct answer.
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!