Write a line (or lines) of code that uses a list that has been previously defined, named word_list, along with a string value entered by the user beforehand, named find, to print out the percent of the occurrence of that word in the list.
As an example, if your word_list looked like this: ['the', 'word', 'I', 'am', 'looking', 'for', 'is', 'called', 'my', 'word']
And find was the string 'word'
The Example Output would look like this:
20.00% of the list is word
Otherwise, if your word_list looked like this: ['another', 'word', 'that', 'is', 'being', 'found', 'is', 'terracotta']
And find was the string 'looking'
That Example Output would look like this:
0.00% of the list is looking
Trending nowThis is a popular solution!
Step by stepSolved in 4 steps with 2 images
- 7. Assume you already have a list defined, called name, containing three strings: aperson’s first, middle, and last name, in that order. Write an expression that produces astring consisting of the person’s last name followed by a comma and space, then the firstname and a space, then the person’s middle initial followed by a period. So, for example,if name is equal to ['John', 'Phillip', 'Sousa'], your expression will produce the string'Sousa, John P.'arrow_forwardJava - Normalizingarrow_forwardyou are given a variable zipcode_list that contains a list. Write some code that assigns True to the variable duplicates if the there are two adjacent elements in the list that have the same value, but that otherwise assigns False to duplicates otherwise. use only variables k, zipcode_list, and duplicatesarrow_forward
- You have a list of student ID’s followed by the course number (separated by a space) that the student is enrolled in. The listing is in no particular order. For example, if student 1 is in CS100 and CS200 while student 2 is in CS105 and MATH210 then the list might look like this:1 CS1002 MATH2102 CS1051 CS200Write a program that reads data in this format from the console. If the ID is −1 then stop inputting data. Use the HashMap class to map from an Integer (the student ID) to an ArrayList of type String that holds each class that the student is enrolled in. The declaration should look like this:HashMap<Integer, ArrayList<String>> students =new HashMap<Integer, ArrayList<String>>();After all data is input, iterate through the map and output the student ID and all classes stored in the vector for that student. The result should be a list of classes organized by student ID.arrow_forwardFor example, suppose the word “robot” is found in lines 7, 18, 94, and 138. The dictionary would contain an element in which the key was the string “robot”, and the value was a list containing the numbers 7, 18, 94, and 138. Once the dictionary is built, you should prompt the user for a word. If the word is found in the dictionary, then print out all the lines on which they are found in ascending order. The code for the print out is provided in the stub code. A stub code is provided for you. If you do not see it, click the "Load default template" button. # The get_word_dict function returns a dictionary containing# the words from line_list as keys, and their line numbers# as values.def get_word_dict(line_list):# Create a line counter.count = 0 # Create a dictionary to hold the words.word_dict = {} # Step through the list of lines.#######Add you code below############# ####################################### Return the dictionary.return word_dict #####DO NOT CHANGE ANYTHING…arrow_forwardGiven list colors = [‘red’ , ‘green’ , ‘blue’] followed by the assignment colors[2]=‘yellow’ Will result in the list colors containing [‘red’ , ‘green’ , ‘yellow’] True or false? arrow_forward
- A chain letter starts with a person sending a letter out to 10 others. Each person is asked to send the letter out to 10 others, and each letter contains a list of the previous six people in the chain. Unless there are fewer than six names in the list, each person sends one dollar to the first person in this list, removes the name of this person from the list, moves up each of the other five names one position, and inserts his or her name at the end of this list. If no person breaks the chain and no one receives more than one letter, how much money will a person in the chain ultimately receive? O 10,000 dollars O 1,000,000 dollars O 500,000 dollars O 100,000 dollarsarrow_forwardPython write a program in python that plays the game of Hangman. When the user plays Hangman, the computer first selects a secret word at random from a list built into the program. The program then prints out a row of dashes asks the user to guess a letter. If the user guesses a letter that is in the word, the word is redisplayed with all instances of that letter shown in the correct positions, along with any letters correctly guessed on previous turns. If the letter does not appear in the word, the user is charged with an incorrect guess. The user keeps guessing letters until either: * the user has correctly guessed all the letters in the word or * the user has made eight incorrect guesses. one for each letter in the secret word and Hangman comes from the fact that incorrect guesses are recorded by drawing an evolving picture of the user being hanged at a scaffold. For each incorrect guess, a new part of a stick-figure body the head, then the body, then each arm, each leg, and finally…arrow_forwardHow would I go about programming this code?arrow_forward
- of range. 3. Use the method swap that you wrote in Exercise 2 to write a method that reverses the order of the items in a list alist.arrow_forwardrun the program and please attach the screenshot of the outputarrow_forwardIn Java: When analyzing data sets, such as data for human heights or for human weights, a common step is to adjust the data. This can be done by normalizing to values between 0 and 1, or throwing away outliers. For this program, adjust the values by subtracting the smallest value from all the values. The input begins with an integer indicating the number of integers that follow. Assume that the list will always contain less than 20 integers. Ex: If the input is: 5 30 50 10 70 65 the output is: 20 40 0 60 55 For coding simplicity, follow every output value by a space, even the last one. Your program must define and call a method:public static int getMinimumInt(int[] listInts, int listSize) import java.util.Scanner; public class LabProgram {/* Define your method here */ public static void main(String[] args) {/* Type your code here. */}}arrow_forward
- 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