Question

Python lab: Problem Statement: In this lab, you will be building a software application that will print the most popular ice-

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

code :

2 flavours.py - C:/Users/G.D.TARUN/Desktop/flavours.py (3.8.0) - X File Edit Format Run Options Window Help def most favorite

output :

---------------- RESTART.L.USEIS, G.D.IHRUIN/ DesκιυΡΙΙΙανοuIS.py ====== The most popular flavor is : chocolate ΑΛΛΛΛΛΛΛΑ >>

raw_code :

def most_favorite_flavour(dic):
most = max(dic.values()) #finding frequency of most popular flavor
for key in dic.keys():
if(dic[key] == most):
return key #returning key of most popualar flavor
def main():
f = open('flavours.txt','r') #opening file
d = {}
for i in f:
k = i.split(' ')
flav = k[1][:-1]
if flav not in d: #counting frequency of flavors
d[flav] = 1
else:
d[flav] +=1
most_favorite = most_favorite_flavour(d) #function to popular flavor
f.close()
print("The most popular flavor is :",most_favorite) #printing result


main() #calling main function
  

  

Add a comment
Know the answer?
Add Answer to:
Python lab: Problem Statement: In this lab, you will be building a software application that will...
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
  • In this lab, you will be writing a complete class from scratch, the IceCreamCone class. You...

    In this lab, you will be writing a complete class from scratch, the IceCreamCone class. You will also write a driver to interact with a user and to test all of the IceCreamCone methods. Lab: • Cone • Ice Cream o Flavor o Topping • Ice Cream Cone • Driver Part I: Cone An ice cream cone has two main components, the flavor of ice cream and the type of cone. Write a Cone class that takes an integer in...

  • You are the operations manager of Spartan Ice Cream Shoppe that produces its own ice cream....

    You are the operations manager of Spartan Ice Cream Shoppe that produces its own ice cream. You make and sell five flavors; Vanilla (v), Chocolate (c), Pistachio (p), Banana (b) and Rocky Road (rr). You want to make as much money as you can, of course. The profits per gallon for the five flavors are Vanilla: $40, Chocolate: $55, Pistachio: $70, Banana: $75 and Rocky Road: $90. You can make up to 200 gallons. You have to make at least...

  • Parallel Arrays Summary In this lab, you use what you have learned about parallel arrays to...

    Parallel Arrays Summary In this lab, you use what you have learned about parallel arrays to complete a partially completed Java program. The program should either print the name and price for a coffee add-in from the Jumpin’ Jive coffee shop or it should print the message: "Sorry, we do not carry that.". Read the problem description carefully before you begin. The data file provided for this lab includes the necessary variable declarations and input statements. You need to write...

  • Lab 1 Q1. Write a Python program with the following function building block. •All input values...

    Lab 1 Q1. Write a Python program with the following function building block. •All input values are to be taken fro m the user. •Ensure to check for possible error cases like mismatch of data type and input out of range, for every function.       Function 1: countVowels(sentence) – Function that returns the count of vowels in a sentence. Function 2: Sum of all even numbers between two numbers, identify number of parameters   Q2. Write a Python program that reads a...

  • Need help with the code for this assignment. Python Assignment: List and Tuples We will do...

    Need help with the code for this assignment. Python Assignment: List and Tuples We will do some basic data analysis on information stored in external files. GirNames.txt contains a list of the 200 most popular names given to girls born in US from year 2000 thru 2009: (copy link and create a txt file): https://docs.google.com/document/d/11YCVqVTrzqQgp2xJqyqPruGtlyxs2X3DFWn1YUb3ddw/edit?usp=sharing BoyNames.txt contains a list of the 200 most popular names given to boys born in US from year 2000 thru 2009 (copy link and create...

  • Practice Problem set 4 (Due Tuesday) Bonus points 3 Name Answer the following questions using the...

    Practice Problem set 4 (Due Tuesday) Bonus points 3 Name Answer the following questions using the data gathered by researchers, from a random sample of undergraduate students during Spring 2015. 1. It is estimated that that Shoe size of adults 18-20 yrs. Follows a normal distribution with mean 9.5 and sd-2 (55 follows N(9.5, 2)). Test if this is true for the sample of 31 students using the 68, 95, 99.5 rule for normal distributions. Interval Number in this interval...

  • NOTE: LANGUAGE IS PYTHON CS160 Computer Science Lab 17 Objectives Work with dictionaries Work with functions...

    NOTE: LANGUAGE IS PYTHON CS160 Computer Science Lab 17 Objectives Work with dictionaries Work with functions Work with files Overview This lab will have you store the birthdays for a group of people. This program will store the information with the focus on the date of the month and not on the individual. The point of this program is to be able to see who has a birthday on a given day or to create a table of birthdays, in...

  • NOTE: LANGUAGE IS PYTHON CS160 Computer Science Lab 17 Objectives Work with dictionaries Work with functions...

    NOTE: LANGUAGE IS PYTHON CS160 Computer Science Lab 17 Objectives Work with dictionaries Work with functions Work with files Overview This lab will have you store the birthdays for a group of people. This program will store the information with the focus on the date of the month and not on the individual. The point of this program is to be able to see who has a birthday on a given day or to create a table of birthdays, in...

  • (IN PYTHON) You are to develop a Python program that will read the file Grades-1.txt that...

    (IN PYTHON) You are to develop a Python program that will read the file Grades-1.txt that you have been provided on Canvas. That file has a name and 3 grades on each line. You are to ask the user for the name of the file and how many grades there are per line. In this case, it is 3 but your program should work if the files was changed to have more or fewer grades per line. The name and...

  • unctions with No Parameters Summary In this lab, you complete a partially prewritten Python program that...

    unctions with No Parameters Summary In this lab, you complete a partially prewritten Python program that includes a function with no parameters. The program asks the user if they have preregistered for art show tickets. If the user has preregistered, the program should call a function named discount() that displays the message "You are preregistered and qualify for a 5% discount." If the user has not preregistered, the program should call a function named noDiscount() that displays the message "Sorry,...

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