Use if-else statements to find the highest score amongst a group of 3 values
4.20 LAB: Who is the best?
Learning Objectives
In this lab we will:
- Use if-else statements to find the highest score amongst a group of 3 values
- Use data structures to retrieve the name that corresponds to the highest score (potentially, in a data structure that makes this easier)
Main Idea
The problem presented in this lab is an active research area in Computer Science called differential privacy and secure (multi-party) computation. In this lab, we won't be able to use a differentially private
Three friends finished the test and want to secretly compare their test scores. They do not want to know each other's exact score, but they do want to know who achieved the best results for this test.
Instructions
-
Input the names and scores of the three friends one after another. (Check out the example input below)
-
Your program should store both names and scores. Think about types to store and structures to store (You can do it in many ways, but we suggest tuples or named tuples or just separate variables.
-
Compare the scores and find the highest.
3.1. If there is one best score - print the name of the friend that achieved that score.
3.2. If there are two friends with equal highest scores - print both names, separated by space, in the order of input.
3.3. If all three friends achieved equal scores - print all three names, separated by space, in the order of input.
Examples
Input
Ann 10 Maria 9 Cindy 7Output
AnnInput
Ann 10 Maria 9 Cindy 10Output
Ann CindyInput
Ann 10 Maria 10 Cindy 10Output
Ann Maria Cindyname1=input()
m1=int(input())
name2=input ()
m2=int(input ())
name3=input ()
m3=int(input ())
string = ""
if(m1>=m2) and (m1>=m3):
large=m1;
elif(m2>=m3) and (m2>=m1):
large=m2;
else:
large=m3;
if large == m1:
string = string +name1
if large == m2:
string = string + name2
if large == m3:
string = string + name3
print(string)
![Output is nearly correct; but whitespace differs. See highlights below.
Special character legend
Ann
10
Betty
Input
9.
Cindy
10
Your output
AnnCindy
Expected output
Ann Cindy
4: Compare output ^
0/1
Output is nearly correct; but whitespace differs. See highlights below.
Special character legend
Ann
8.
Betty
Input
10
Cindy
10
Your output
BettyCindy
Expected output
Betty Cindy](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F65d4b7c1-bff9-4699-bca1-37915a859545%2Fa546f73e-c67d-421a-afe5-7715ee6d3940%2Fin5tkl_processed.png&w=3840&q=75)
![1: Compare output ^
1/1
Ann
10
Betty
Input
9.
Cindy
8
Your output
Ann
2: Compare output a
0/1
Output is nearly correct; but whitespace differs. See highlights below.
Special character legend
Ann
10
Betty
Input
10
Cindy
8.
Your output
AnnBetty
Expected output
Ann Betty](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F65d4b7c1-bff9-4699-bca1-37915a859545%2Fa546f73e-c67d-421a-afe5-7715ee6d3940%2Fktqzpx_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)