Write a function that will play Rock, Paper, Scissors with itself. It will pick two random elements from a list. Then the function must know if random element #1 won, lost or drawed. The list is rps=['rock', 'paper', 'scissors'] Then the function must add to a dictionary the number of times the first element won per option in the list. Example { 'rock':'400', 'paper':'300', 'scissors':'300' } You need to run this at least 1000 times. You can either create a single thread, or you can create multiple threads. You need to use the random module and the random.choice(LISTNAME) to pick a random element from a list.
Q: Write a function high_low_dict(numbers, sep) that takes a list of numbers and an int sep that will…
A: Note: The problem solved in JAVA. ALGORITHM: -> take a ArrayList to add elements and an int type…
Q: Write a function named `freq(l)` that takes a list `l` of numbers and returns a tuple of the most…
A: Here is the python3 code implementation of above problem. For input1:…
Q: Write a function remove_smallest() that gets a dictionary as a parameter and remove the item which…
A: def remove_smallest(data): #find min value in dict value=min(data.values()) #create new…
Q: Write a function that will accept a dictionary as the input parameter and return a new dictionary…
A: Use reversed to reverse the dictionary
Q: L = [A, R, T, M] M = Reverse(L) Print(L.ToString()) → Prints [A, R, T, M] Print(M.ToString()) →…
A: Python is the high-level interpreted programming language, that's used to build web browser…
Q: Write a function multiply_ends(nums) that takes a non-empty list of integers and returns the first…
A: 1. declare function with parameter nums i. get first element i.e. 0ith index element…
Q: Write a function piggyBank in Python that accepts a sequence of "coins" and returns counts of the…
A: The value of each coin is: A penny is worth 1 cent. A nickel is worth 5 cents. A dime is worth 10…
Q: Can you answer with Python programming language ? Write a function that takes two arguments: stock…
A: The program loops through each item in stock for the required item i.e.for the first item in the…
Q: Write a program that will take this dictionary: gradePoints = {"A":4,"B":3,"C":2,"D":1,"F":0} and…
A: The average of the academic is determined by dividing the total amount of quality points earned for…
Q: how do i test this javascript function the function and directions for function are as follows…
A: Please refer to the following step for the complete solution of the problem above.
Q: Write a function that takes in the head of a Singly Linked List and an integer k , shifts the list…
A: The code of the above given question is as given below:
Q: Write a program in Python for a marathon race. In your program include the following • A dictionary…
A: We have to write Python code for the following Question:
Q: Write a function that takes a list removal(L), delete from it all the elements whose indices are…
A: Algorithm: Start Initialize a list with given data Define a method named removal which takes the…
Q: Please answer it in Python Write a function insere_milieu that takes as an argument a list l and an…
A: The asked python program is coded in the next step and is explained within comments in the program.…
Q: Write the nondestructive function insertRowCol(L, row, col, val) which takes a rectangular 2D list L…
A: Program Plan: Function insertRowCol has 4 parameters: arr - input arrayr - Row to insert the valuec…
Q: Write a function that takes a list as a parameter. The list will contain a mixture of integers and…
A: Rawcode: #asking user to enter list elements elements = input("Enter the list elements: ")…
Q: Please answer it in Python Write a function extrait_pairs that takes as an argument a list l1 and…
A: 1) Below is python program that define a function extrait_pairs that takes as an argument a list l1…
Q: Please answer it in Python write a function word_vers_dictionary(word), which takes a word…
A: According to company guidelines we are supposed to answer only one question. Kindly repost other…
Q: main.py 1 Fill in the blank in the function below with a single line of code, such that if pairs is…
A: upper() method converts all lowercase characters in a string into uppercase characters and returns…
Q: Generate equally spaced coordinates We wish to generate n + 1 equally-spaced z coordinates in [a,…
A: """Python program to create linspace function and test its generated list""" #linspace function…
Q: Write a function differBy which takes two arguments, a number N and a list of numbers L, and returns…
A: ; (write-line "Hello World") (defun differBy (N list-data) (setq ans nil) ; initialize list to…
Q: Write a program that will take this dictionary using python : gradePoints =…
A: import random gradeList = ["A", "B", "C", "D", "F"]gradePoints = {"A" : 4, "B" : 3, "C" : 2, "D" :…
Q: Write a function in python, cannot use isalpha or .get named count_letters that takes as a parameter…
A: I give the code in Python along with output and code screenshot
Q: in python write a function where it makes a dictionary from given text file. If no value is present…
A: SUMMARY: - Hence, we discussed all the points.
Q: 1. Write a function that takes in a list and returns a new list that has the elements of the…
A: Given :
Q: Instructions are given within the quotations for each function. 1)def remove_duplicate_sorted(t):…
A: t = [1, 3, 5, 6, 3, 5, 6, 1] print ("The original list is : " + str(t)) res = [] [res.append(x)…
Q: deleted element x. MANDATORY FOR CODE TO BE IN P
A: Write a function Delete(x,L) in Pascal that deletes last occurrence of x in a singly linked list and…
Q: Write a python program... Write a function called merge2(d1,d2) that takes two dictionaries as…
A: Given: Write a python program... Write a function called merge2(d1,d2) that takes two dictionaries…
Q: ut name of new employee : Mike Menu : 1 . Print full list of employees 2 . Insert new employee 3 .…
A: code : #include <iostream>#include <string>using namespace std; class List{public:…
Q: Write a function that will accept a dictionary as the input parameter and return a new dictionary…
A: Hi. As there is no programming language mentioned, I will attempt this question using Python.…
Q: Complete the code below so that the function combines the counts of the same key. The function takes…
A: Check whether key is present in dictionary or not If key is present, we add up the value to existing…
Q: Write a function named dictMax which takes two arguments: a dictionary and a list. Your function…
A: Initialize the return value to None and in the initial value we simply update None with our…
Q: Let's assume that a player plays a multi-agent game where, every gun has a type: "Sidearms" or…
A: def function(t): d={} for i in t: for j in i: if i[j][0] not in d:…
Q: Write a function called merge2(d2,d2) that takes two dictionaries as input parameters. This function…
A: def merge(d1, d2): d3 = {} for key in d1: d3.setdefault(key, [])…
Q: Write a function addToAll(Ist, x) which takes a list of integers and a number and modifies the list…
A: Iterate over the given list and update element by adding x value to it
Q: PYTHON!!!! Write a function that takes a dictionary representing points in 3D space and an…
A: Objective: This program takes a dictionary and computes the centroid of co-ordinates. Also, the…
Q: Suppose a node of a linked list is defined as follows in your program: typedef struct{ int…
A: Since the programming language is not mentioned, we are providing answers in C++ language. The code…
Q: The function returns the absolute value of the sum of the every other nth element of L
A: Program: # Python Version 3# function to return the absolute value of the sum of the list…
Q: Write a function countRange() that takes three parameters, a list and two numbers, finds and returns…
A: I have given an answer in step 2.
Q: Write the following function to sort a list of points on their y-coordinates. Each point is a list…
A: Code def sort(a): n = len(a) for i in range(n): for j in range(n-1): if…
Q: Let D be a Python dictionary whose values are non-negative integers, and whose keys are arbitrary…
A: Iterate over the given dictionary entries and whenever we have the value as maximum, we can append…
Q: Write a function countdown321 (nums) that returns True if the sequence 3, 2, 1 appears in the list…
A: Given:
Q: Our second pattern is the mapped list pattern, described in video 4 3 mapped list pattern. Often we…
A: The for loop in Python is used to iterate the statements or a part of the program several times. The…
Q: Use Python for this question: Write a function piggyBank that accepts a sequence of "coins" and…
A: def piggyBank(coins): sum = 0 total = {'Q':0,'D':0,'N':0,'P':0} for i in coins:…
Q: Write a function removeN which takes three arguments called N, E and L (where L is a list) and…
A: Find the code attached. package com.company;import java.util.*;public class Main { public static…
Q: Write the following function that partitions the list using the first element, called a pivot:def…
A: function that partitions the list using the first element, called a pivot:def partition(lst): After…
Q: this code should be in python: write a function that receives a list as its only parameter. Inside…
A: Introduction: this code should be in python: write a function that receives a list as its only…
Q: Write a function that takes two lists as input, a list L1 containing characters and a list L2…
A: I have provided PYTHON CODE along with CODE SCREENSHOT and OUTPUT SCREENSHOT------------
Q: Write a function named freq(1) that takes a list `1 of numbers and returns a tuple of the most…
A: res=freq([1,2,3,1,2,1,2,3,1,2]) Output:([1,2], 4)
PYTHON LANGUAGE
Step by step
Solved in 2 steps with 2 images
- Write a function that gets a linked list of ints, and reverses it. For example - on input 1 -> 2 -> 3 -> 4, after the function finishes the execution, the list becomes 4 -> 3 -> 2 -> 1 - If the list has one element, then it doesn’t change - If the list is empty, then it doesn’t change You may use the data fields in the struct and the functions provided in LL.h and LL.c. // reverses a linked list void LL_reverse(LL_t* list); Test for the Function; void test_q3() { LL_t* lst = LLcreate(); LL_add_to_tail(lst, 1); LL_add_to_tail(lst, 3); LL_add_to_tail(lst, 8); LL_add_to_tail(lst, 4); LL_add_to_tail(lst, 3); LL_reverse(lst); intcorrect[] = {3,4,8,3,1}; inti; node_t* n = lst->head; for(i=0;i<5;i++) { if (n==NULL) { printf("Q3 ERROR: node %d==NULL unexpected\n", i); return; } if (n->data != correct[i]) { printf("Q3 ERROR: node%d->data==%d, expected %d\n", i, n->data, correct[i]); return; } n = n->next; } if (n==NULL) printf("Q3 ok\n"); } Support File…Write a function that takes a list removal(L), delete from it all the elements whose indicesare divisible by 3. And return the resulting list after removing unwanted elements.Example:>>>removal(['A', 'B', 'C', 'D', 'E'])['B', 'C','E'Write a function piggyBank in Python that accepts a sequence of "coins" and returns counts of the coins and the total value of the bank. the coins will be given by a list of single characters, each one of 'Q','D','N',P', representing quarter, dime, nickel, penny the function returns a tuple with two items:1. a dictionary with counts of each denomination. They should always be listed in theorder 'Q','D','N',P'2. the total value in whole cents of the amount in the bank Sample result examples: >>> piggyBank(['D', 'P', 'Q', 'Q', 'D', 'P', 'P'])({'Q': 2, 'D': 2, 'N': 0, 'P': 3}, 73) >>> piggyBank(['D', 'D', 'N', 'N', 'N'])({'Q': 0, 'D': 2, 'N': 3, 'P': 0}, 35) >>> piggyBank(['P', 'D', 'N', 'P', 'N', 'N', 'N', 'Q', 'D', 'P', 'Q', 'Q', 'D'])({'Q': 3, 'D': 3, 'N': 4, 'P': 3}, 128) >>> piggyBank(['D', 'P', 'Q', 'Q', 'D', 'P', 'P'])==({'Q': 2, 'D': 2, 'N': 0,'P': 3}, 73)True Please only give to me the final code or "tool" that could generate any of the…
- Write a python program... Write a function called merge2(d1,d2) that takes two dictionaries as input parameters. This function will create a new dictionary that contains everything from the two input dictionaries and return it. The same key might appear in both input dictionaries. In the output dictionary, the value for each key will be a list that has all values corresponding to this key in the two input dictionaries. Sample run,>>> d1 = {'a': 100, 'b': 200, 'c':300}>>> d2 = {'a': 300, 'b': 200, 'd':400} >>> d3 = merge2(d1,d2)>>> display(d3)a, [100,300]b, [200,200]c, [300]d, [400]Write a function letter_count that accepts a string txt and returns a list containing the number of times that each letter of the alphabet occurs within txt. The returned list should contain the number of occurences of all twenty-six letters of the Latin alphabet, counting both upper and lower-case instances. For example, the string 'Abacus' contains two instances of the letter 'a', and so the first element of the returned list would be 2Write a function averageB in Python that has a parameter scoreDict which is a dictionary where the keys are strings and the values are floating point numbers representing scores. The function returns the average score for all keys that start with a b (uppercase or lowercase) or returns 0 if there are no keys that start with b.
- Write a function with the signature below that returns the sum of the last k elements of a singly linked list that contains integers. int returnSumOfLastKNodes(Node* head, int k) Example: 10 -> 5->8->15->11->9->23 10 represents the head node, returnSumOfLastKNodes(Node* head, 4) will return 58.Write a function that takes two arguments: stock and ingr (short for ingredients) and returns the missing ingredients in stock. stock is a dictionary containing (key,value) pairs in the form of ("potato", 5).The key is the name of an ingredient, and the vlaue is its existingamount. ingr is a list of tuples, where each tuple represents the requiredamount of an ingredient. For example, ("cheese", 3) means we need 3 units of cheese for this recipe. Your function checks whether we have enough of each itemin the stock. If an item is missing or not enough then your function returns the missing amount within a list of all such items. If all items are in stock, then you return an empty list. For example: stock = {"salt":100, "sugar":100, "flour":50, "apple":3, "cream":10}ingr = [("sugar",50), ("flour", 120), ("apple",5)] checkStock(stock, ingr) should return [("flour",70), ("apple",2)] which means we need 70 more units of flour and 2 more apples for this recipe.Note that it is possible for an…Write a function that takes two arguments: stock and ingr (short for ingredients) and returns the missing ingredients in stock. stock is a dictionary containing (key,value) pairs in the form of ("potato", 5).The key is the name of an ingredient, and the vlaue is its existingamount. ingr is a list of tuples, where each tuple represents the requiredamount of an ingredient. For example, ("cheese", 3) means we need 3 units of cheese for this recipe. Your function checks whether we have enough of each itemin the stock. If an item is missing or not enough then your function returns the missing amount within a list of all such items. If all items are in stock, then you return an empty list. For example: stock = {"salt":100, "sugar":100, "flour":50, "apple":3, "cream":10}ingr = [("sugar",50), ("flour", 120), ("apple",5)] checkStock(stock, ingr) should return [("flour",70), ("apple",2)] which means we need 70 more units of flour and 2 more apples for this recipe.Note that it is possible for an…
- Write a Python function countEvens that consumes an integer N and a nested list representing a matrix of arbitrary size (but larger than NxN). The function returns the number of even numbers in the NxN sub-matrix of the first N rows and columns. Note: You may assume the list argument passed to the function is a nested list of integers, but it may be larger than NxN!Can you answer with Python programming language ? Write a function that takes two arguments: stock and ingr (short for ingredients) and returns the missing ingredients in stock. stock is a dictionary containing (key,value) pairs in the form of ("potato", 5).The key is the name of an ingredient, and the value is its existingamount. ingr is a list of tuples, where each tuple represents the requiredamount of an ingredient. For example, ("cheese", 3) means we need 3 units of cheese for this recipe. Your function checks whether we have enough of each itemin the stock. If an item is missing or not enough then your function returns the missing amount within a list of all such items. If all items are in stock, then you return an empty list. For example: stock = {"salt":100, "sugar":100, "flour":50, "apple":3, "cream":10}ingr = [("sugar",50), ("flour", 120), ("apple",5),("orange",25),("salt",40)] checkStock(stock, ingr) should return [("flour",70), ("apple",2),("orange",25)] which means we need…Write a Python Code for the given function and conditions: Given function: def insert(self, newElement) Pre-condition: None. Post-condition: This method inserts newElement at the tail of the list. If an element with the same key as newElement already exists in the list, then it concludes the key already exists and does not insert the key.