Write a program called p2.py that contains a function called word_selection () that takes a list as a parameter and randomly selects one item in the list and prints it. Your program should have the following functionality: 1. Continuously prompt the user to enter a word until the user enters q 2. Store the entered words in a list 3. Making use of the random module, your program should call word_selection() that randomly selects a word from the list and prints it 4. Include the guard for the main function: if name main main() Example:
Q: Python Write a function compute_stats, such that given a list of grades as an input parameter, it…
A: Python in-built functions used in the program: sum() - sums up the numbers in the list. len() -…
Q: Write a program called a2_q1.py that asks the user (business owner) for their product information…
A: class a2_p1(object): def validateAndDisplayMenu(self,num): #function to prompt user…
Q: Your task is to implement a variation of the classic word game Hangman, which involves players…
A: Coded using Python 3.
Q: Write python code 1) Write a function verifsort that accepts a list as a parameter, check if the…
A: The problem is based on the basics of functions in python programming language.
Q: rite a function named min_or_max_index that has two parameters: a list and a bool. If the Boolean…
A: def min_or_max_index(L, flag):""" (list, bool) -> tuple of (object, int)Return the minimum or…
Q: Write an application that accepts up to 20 Strings, or fewer if the user enters the terminating…
A: Actually, java is a object oriented programming language. It is a platform independent.
Q: Create a two-string activity, $ a and $ b. Repeat times when two strings contain the same two…
A: Algorithm: Start Implement a function named strMatchBy2char() that takes two strings $a and $b If…
Q: Write a function print_numbered_items (items) that takes a list of items and prints them one per…
A:
Q: A group of statisticians at a local college has asked you to create a set of functions that compute…
A: def median(list): n=len(list); if(n==0): return 0; else: list.sort();…
Q: End of semester grades are quickly approaching and some nice guy hacker wants to write a function…
A: Solution: Given, End of semester grades are quickly approaching and some nice guy hacker wants to…
Q: Write a function compute_stats, such that given a string of grades as an input parameter, it calls…
A: Explanation Python in-built functions used in the program: sum() - sums up the numbers in the…
Q: Using the code below, answer the following questions: 1) What are each of the 3 functions…
A: NOTE - As per our guidelines we are supposed to answer only the first three parts, please re-submit…
Q: Suppose you are given a function in module foo named `function loop_string_reverse_all that accepts…
A: I have provided PYTHON CODE along with CODE SCREENSHOT and OUTPUT SCREENSHOT
Q: A supermarket wants to reward its best customer of each day, showing the customer’s name on a screen…
A: As programming language is not provided I am assuming it to be python. Program code is given below.…
Q: Develop a program that gets a list of student grades and find: grade average, max grade, and min…
A: Input : Input grades of students Output : Average grade Maximum grade Minimum grade
Q: python / def get_new_grades(): """ Write a function get_new_grades, such that given a string of…
A: Python code to perform the given function with conditions as given below.
Q: Write a function convert_to_millimetres (measurements) which takes a list of measurements in…
A: def convert_to_millimetres(measurements): for i in range(len(measurements)):…
Q: Write a Python program that will use 5 functions in total: 1. A function which will declare a list.…
A: Read the inputs. Process them. Print the output. Exit.
Q: Write a python program to display a receipt of ordered foods by a customer at a restaurant. The…
A: Based on python
Q: group of statisticians at a local college has asked you to create a set of functions that compute…
A: Algorithm: Start Implement a method named mean() that takes data (a list) as argument Inside the…
Q: Write a program called a2_q1.py that asks the user (business owner) for their product information…
A: Answer: Here we have to determine python code for business owners program. Python programming…
Q: our task is to implement a variation of the classic word game Hangman
A: This is very simple. I have written all the functions asked in the problem. Have a look at the…
Q: Write a python program that contains a function called word_selection() that takes a list as a…
A: Python program for above : import random def word_selection(words): if(len(words)):…
Q: 1. Create the functions sadness_score, and happiness_score 2. Each function has only 1 parameter of…
A: Step 1: Define function sadness_score(). Initialize list consisting of words and their weights.…
Q: ollege has asked you to create a set of functions that compute the median and mode of a set of…
A: Introduction: Below describe the python function these functions, median and mode, in a module named…
Q: in javascript create a function that does the following and named as such, please dont copy the…
A: Algorithm Steps:- Initialize an empty Array for the final result Initialize a temporary array to…
Q: Write a program that reads a list of names and total points for students until -1 is entered. After…
A: Given data is shown below: Write a program that reads a list of names and total points for students…
Q: Please answer it in python Write a ReadListInteger function without arguments that reads positive…
A: As all the questions are not related to each other. As per the rules of Bartleby I can only solve 1…
Q: A group of statisticians at a local college has asked you to create a set of functions that compute…
A: def mean(lyst): s=0 #check if list is empty if(len(lyst)==0): return 0 #find sum…
Q: We are going to write a program to create a word puzzle. For now, what we need is a function…
A: clear;clc[l, n] = promptletnum;fprintf('We will find words that contain the \n')fprintf('letter'' %c…
Q: Write an application that accepts up to 20 Strings, or fewer if the user enters the terminating…
A: Objective: This program reads a maximum of 20 Strings until the user inputs the sentinel value ZZZ.…
Q: Write a program in C++ that finds the count of a number in a list of integers from a text file named…
A: Here is the c++ code: See below step for code.
Q: Write an application that accepts up to 20 Strings, or fewer if the user enters the terminating…
A: import java.util.ArrayList;import java.util.Scanner; public class CategorizeStrings { public…
Q: Write a function called multTable that returns void, takes in an int row and, int col and prints the…
A: The program prompts the user to enter row index and column index till which the multiplication table…
Q: Write a function timestable(n), which prints a multiplication table of size n. For example,…
A: Python code and code screenshot is given below and Output is also given below:
Q: Define a function named get_encrypted_list (word) which takes a word as a parameter. The function…
A: Please refer to the following steps for the complete solution to the problem above.
Q: Write a Python function called sumList () which will receive a list of integers as input parameter.…
A: Note: we are only allowed to solve one question in one post. I am solving the first on here. To get…
Q: write a python code named get_total_cases() takes the a 2D-list (similar to database) and an integer…
A: Coded using Python 3.
Q: So the programming language for this problem is python. How do I create a function that allows the…
A: In this python program, The user is asked to enter an array of integers. First index of this array…
Q: A group of statisticians at a local college has asked you to create a set of functions using python…
A: Note: I use tutorialspoint.com online compiler for executing the Python program Program:…
Q: You are tasked with helping write part of an exciting new word-guessing game, “Durdle”. The game is…
A: Python Code: def durdle_match(a, b): word="" for i in range(5): if(a[i]==b[i]):…
Q: n this problem, you have available to you a working version of the function round_up described in…
A: source code sol.py import foo def round_up_all(lst): for i in range(len(lst)): lst[i] =…
Q: I need help Note: It`s a python Implement the following: 1) Define a function oddList() with an…
A: Solution: Given, 1) Define a function oddList() with an arbitrary parameter a.2) This function…
Q: Write a function named addCommas that accepts a string representing a number and returns a ew string…
A: #include "strings.h"std::string addCommas(std::string const &s){ std::string str = s; int…
Q: Write a function to return a list of the Fibonacci sequence up to x terms The Fibonacci Sequence is…
A: def fibonacci(n): flist = [] q=0 w=1 i=0 flist.append(0) while(i<n-1):…
Q: Create a program that has a function that takes one integer argument. The function will print a list…
A: - The question to to code the number division list problem provided.
Q: IN SCALA COULD YOU COMPLETE THE FUNCTIONS: is_legal, legal_moves, count_tours, enum_tours, first,…
A: Mentioned below the remaining function as follows,
Q: create a javascript function and show it working that myChoice( items ) This function accepts a…
A: This function accepts a list of items as input and creates a function that returns a randomly chosen…
Q: Write a function divisibleBy which takes two arguments, a numberN and a list of numbers L, and…
A: According to the information given:- We have use Programming language Schema Racket to write…
Step by step
Solved in 2 steps with 1 images
- Problem 2Write a program called p2.py that contains a function called less_than_age() that takesa string filename and an integer x as parameters. You can assume that this file containsa list of comma-separated animal names and their ages, similar to the content in thesample file above. This function should store the names of all the animals with age lessthan x in a list and return the list.Again, test your function inside main().Sample output:>>> result = less_than_age(“samplefile_t9.txt”, 4)>>> print(result)[“wombat”, “koala”, “dingo”, “kookaburra”]Write a python program that accepts floating point values saved in list. There should be 3 functions in your program that accepts the list as parameter: one that averages the list elements, one that gets the highest and lowest entered values (without sorting the list), and one that totals the list elements. Ask the user which function task to perform and allow them to repeat the process if they wish to.Create a function that will take a list and returns a new list with the duplicates removed. It also returns the number of duplicates removed. The user may choose to get the data in order or sorted by sending a boolean order. Sample input [1 1 7 7 7 7 2 2 2 2 2 1 4 5 6 7 8 9 2 3 1 1 3 4 2 5 6 7 8 8] Sample output if the same order was needed [1 7 2 4 5 6 8 9 3]. 21 duplicates removed. Sample output if ordering was requested [1 2 3 4 5 6 7 8 9]. 21 duplicates removed
- In this problem, you have available to you a working version of the function round_up described in part (a). It is located in a module named foo. Using the given round_up function, write a function round_up_all that takes a list of integers and MODIFIES the list so that each number is replaced by the result of calling round_up_ on that number. For example, if you run the code, 1st = [43, 137, 99, 501, 300, 275] round_up_all(1st) print(1st) the list would contain the values [100, 200, 100, 600, 300, 300] Do not re-implement the round_up function, just import the food module and use it. Here is the code for the round_up function that can be imported using foo: def round_up(num): if num % 100 == 0 : #if number is complete divisible return num #return orginal num else: return num + (100-(num % 100)) #else add 100-remainder to num, if __name__ == '__main__': print(round_up(234)) print(round_up(465)) print(round_up(400)) print(round_up(89))Python Question, use a docstring and add comments throughout the code, please show all work Write a function buildBigger() that takes a two-dimensional list and a number num as parameters and returns a list of all the values in the parameter list that are greater than or equal to num. If all the values in the parameter list are less than num, the function returns an empty list. You should assume that the function will be provided a 2D list containing only numeric (i.e., int or float) values and that the second parameter is also an int or float. If the list provided as a parameter is empty, the function should return the empty list. The function should not alter the list provided as a parameter. Below are some sample executions of the function. Use the nested loop pattern and an accumulator list in the solution. Don’t forget to include the docstring and comments. Submissions that don’t include all will lose points. Copy and paste or screen shot the code and the eight test cases shown…Using the code below, answer the following questions: 1) What are each of the 3 functions responsible for? 2) How many parameters will each function have? 3) What does each function return? 4) How will the program be controlled? 5) What functions will it call? 6) How will it communicate the results with the user? ********************************************* Code starts here ************************************************** Module.py #Defination to sort the list def sort(listNum): sortedList = [] #While loop will run until the listNum don't get null while(len(listNum) != 0 ): #Set the min as first element in list min = listNum[0] #iterate over the list to compare every element with num for ele in listNum: #If element is less than min if ele < min: #Then set min as element min = ele #append the sorted element in list sortedList.append(min) #Remove…
- A group of statisticians at a local college has asked you to create a set of functions that compute the median and mode of a set of numbers, as defined in Section 5.4. Define these functions in a module named stats.py. Also include a function named mean, which computes the average of a set of numbers. Each function should expect a list of numbers as an argument and return a single number. Each function should return 0 if the list is empty. Include a main function that tests the three statistical functions. Ask users to enter the list of numbers, and then choose which function to apply to those numbers. After the single number is returned from the correct function, display to the user the list of numbers, the function selected and the answer in a format that is easy to understand.Remember to include the docstring, and explain it step by step. Write a function named square_list that takes as a parameter a list of numbers and replaces each value with the square of that value. It should not return anything - it should mutate the original list. Your function could be used like this: nums = [4, -5, 13, 8] square_list(nums) print(nums) # This should print [16, 25, 169, 64]Need done in python, picture of the homework question is provided. Answer any ONE (highlight your choice) of the following two problems: Problem A Write a function definition which has two parameters, both lists. The function is supposed to return the “product” of the two parameters. The result which is returned is a new list whose elements are the products of corresponding elements from each list. If the lists are not the same size, return an empty list. Assume the elements are numeric. Use ONE return statement. This function does no input or output. Example: times_list( [2, 4, 5], [3, 4, 9]) returns [6, 16, 45]. Example: times_list( [3, 15], [1, 2, 3]) returns [ ] Problem B Write a program that plays a number-guessing game with the user. The program first generates a random number in the range 1 through 50, inclusive. The user then enters a guess. If the user matches the random number, the game is over, and shows how many guesses it took. If the…
- Write a function that takes as input a list of elements and returns a list with elements and their position after. For example, if the input to the function is (list ’a ’b ’c) then it will return (list a 1 b 2 c 3). Make sure to use a for loop in your function, and explain how it works by adding comments to your code. Make sure to submit the Racket file.Please write a full C++ code The function insert of the class orderedLinkedList does not check if the item to be inserted is already in the list; that is, it does not check for duplicates. Rewrite the definition of the function insert so that before inserting the item, it checks whether the item to be inserted is already in the list. If the item to be inserted is already in the list, the function outputs an appropriate error message. Also, write a program to test your function Also please allow the code to be copied. Don't just provide a screenshotWrite a function that takes two arguments, a list L1 and a list L2. • If the length of the list L1 is greater than twice the length of the list L2, then append the first three values of L1 to the three last values of L2. E.g. if L1 = ‘(1 2 3 4 5 6 7) and L2 = ‘(8 9 10), then return ‘(1 2 3 8 9 10) Should be written in the Racket programming language