Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
Write a program that reads a list of words. Then, the program outputs those words and their frequencies (case insensitive).
Ex: If the input is:
hey Hi Mark hi markthe output is:
hey 1 Hi 2 Mark 2 hi 2 mark 2Hint: Use lower() to set each word to lowercase before comparing.
My code:
my_list = input()
my_list_lower = my_list.lower()
list = my_list_lower.split()
for word in list:
freq = list.count(word)
print(word, freq)
the program wants the lower case number count AND for the list of words to remain upper case if they were upper case. how do i make it do that?
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 4 steps with 2 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Write a program called p3.py. Your program should have the following functionality: 1. Randomly selects a word from a pre-set list: kangaroo, capybara, wombat, koala, wallaby, quokka, platypus, dingo, kookaburra 2. Prompts the user to guess a letter 3. Validates the input 4. If the letter is not in the word, print a message reflecting this 5. Prints the word where all guessed letters are revealed and all unguessed letters are replaced by underscores hint : consider storing the guessed letters in a list 6. The program should continuously prompt the user to guess letters until they enter ‘quit’ or all the letters in the word have been guessed 7. Don’t forget to include the main guard Example of output: The program selects the word quokka, but the user does not know Guess a letter: a _____a Guess a letter: e there is no ‘e’ _____a Guess a letter: k ___kka Guess a letter: u _u_kka Guess a letter: o _uokka Guess a letter: q quokka You win! Good job!arrow_forwardWhen analyzing data sets, such as data for human heights or for human weights, a common step is to adjust the data. This adjustment can be done by normalizing to values between 0 and 1, or throwing away outliers. For this program, adjust the values by dividing all values by the largest value. The input begins with an integer indicating the number of floating-point values that follow. Assume that the list will always contain positive floating-point values. Output each floating-point value with two digits after the decimal point, which can be achieved as follows:print(f'{your_value:.2f}')arrow_forwardplease explain pythonarrow_forward
- Write a program that uses 2 lists. Call the lists Items and Basket respectively. The first list will contain a list of at least 10 items (make up your own items) to select from. The second list will be used to add the selected items in the new list.(Basket) Your program should do the following in a Loop until the user exits the loop: Display the list (print out 1, 2, 3, 4, etc. before each item in the list (Hint: Use Index + 1) Prompt the user to select an item from the Items list. Add the selected item to the new list (Basket) (HINT: Use number entered - 1 for the Index) When the user selects 0, exit the loop and print out the new list of items (Basket) Use Microsoft Word to create your Outline and Logic sections. You can copy and paste your Python code at the end under the heading "Code:" Upload your work into the assignment when completedarrow_forwardWrite a program that first gets a list of integers from input. The input begins with an integer indicating the number of integers that follow. Then, get the last value from the input, which indicates a threshold. Output all integers less than or equal to that last threshold value. Assume that the list will always contain less than 20 integers. Ex: If the input is: the output is: 5 50 60 140 200 75 100 The 5 indicates that there are five integers in the list, namely 50, 60, 140, 200, and 75. The 100 indicates that the program should output all integers less than or equal to 100, so the program outputs 50, 60, and 75. For coding simplicity, follow every output value by a comma, including the last one. Such functionality is common on sites like Amazon, where a user can filter results. 5 6 50,60,75, 1 #include 2 3 int main(void) { 4 78991 11 10 } const int NUM_ELEMENTS = 20; int userValues [NUM_ELEMENTS]; /* Type your code here. return 0; // Set of data specified by the userarrow_forwardWrite a program to understand customer waiting time. A list provides the number of customers that arrive every minute for 10 minutes. The program should output the length of the line at each minute, assuming one clerk serves each customer and takes 1 minute to complete service. If the input is 2 0 0 2 1 0 0 0 1 0, the output should be 2 1 0 2 2 1 0 0 1 0 (At minute 0, 2 customers arrived in line. At minute 1, 1 of those has been served, reducing the line to 1. At minute 2, that customer was served, reducing the line to 0). Output a space after each output integer, including the last (followed by newline). Hints: Every minute, if the lineLength wasn't 0, you can decrement lineLength because the clerk would have finished serving one customer. Every minute, if new customers arrived, just add them to lineLength for that minute.arrow_forward
- Write a program that reads a list of integers, and outputs whether the list contains all even numbers, odd numbers, or neither. The input begins with an integer indicating the number of integers that follow. Ex: If the input is: 5 2 4 6 8 10 the output is: all even Ex: If the input is: 5 1 3 5 7 9 the output is: all odd Ex: If the input is: 5 1 2 3 4 5 the output is: not even or odd Your program must define and call the following two functions. is_list_even() returns true if all integers in the list are even and false otherwise. is_list_odd() returns true if all integers in the list are odd and false otherwise.def is_list_even(my_list)def is_list_odd(my_list) if __name__ == '__main__': both def and if need to be included and functions called from both defs def is_list_even(my_list):for i in range(len(my_list)):if my_list[i] % 2 != 0:return False or Truedef is_list_odd(my_list):for i in range(len(my_list)):if my_list[i] % 2 == 0:return False or Trueif is_list_odd == True:print("all…arrow_forwardWrite a program that uses 2 lists. Call the lists Items and Basket respectively. The first list will contain a list of at least 10 items (make up your own items) to select from. The second list will be used to add the selected items in the new list.(Basket) Your program should do the following in a Loop until the user exits the loop: Display the list (print out 1, 2, 3, 4, etc. before each item in the list (Hint: Use Index + 1) Prompt the user to select an item from the Items list. Add the selected item to the new list (Basket) (HINT: Use number entered - 1 for the Index) When the user selects 0, exit the loop and print out the new list of items (Basket)arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education