listLine = < *** Hello *** There! *** > The value of size after this code is executed is 4 listLine = line.split("***") size = len(listLine)
Q: Create a program that asks the user to enter (n) the number of elements that will b in the list. The…
A: Note- since programming language is not mentioned so we are providing answer in python programming.…
Q: Write a Python function that takes a list and returns a new list with the first list's unique…
A: def fun(l): d={} for i in l: if i not in d: d[i]=1 return d.keys()print('Enter space separated…
Q: Assume list1 references a list. After the following statement executes, list1 and list2…
A: Answer: F
Q: Write a program that reads a list of integers, and outputs whether the list contains all even…
A: Hi. Let's move on to the code in the next step. I have included comments in the code that will…
Q: Guess 1-9 for player number 1: 80 Invalid number, enter 1-9: -10 Invalid number, enter 1-9: 6 Guess…
A: Answer the above program are as follows
Q: Exercise 3: Write a program that reads from an input file "scores.txt" student test scores in he…
A: The split function in python language : The split function takes a delimiter as input and splits the…
Q: paython programing question Write a program that creates a list of N elements (Hint: use append()…
A: Note: Code comments have been added in the source code itself to have a better understanding of the…
Q: dict = { 'a': [1,2,3,4] 'b': [3,6,7,8] 'c': [9,1,9,1] { Iterate over the above dictionary…
A: Please refer below code and output for refrence: Every line is commented : dict = { 'a':…
Q: Problem Statement: Remove duplicate values from list In this lab, you will be building a software…
A: """Application that remove the duplicate values from the list""" #user define function to perform…
Q: 1.Write a statement that creates a list with the following strings: 'Einstein', 'Newton',…
A: The strings given are: 'Einstein', 'Newton', 'Copernicus', and 'Kepler'.Below is the code to create…
Q: while user_input >0: #This is the number that is greater than 0 from the list that is entered.…
A: Here I have created an empty list that will store the numbers entered by the user. Next, I have…
Q: Create a program that outputs a given number of unique random values between 1 and 100. The program…
A: Task :- Create a python program to generate random numbers. Python program :- import random n =…
Q: def longest_chain(lst: List[int]) -> int: Given a list of integers, return the length of the longest…
A: Please find the answer below :
Q: s are yellow limes are green then the list ["red", "yellow", "green"] s
A: def last_words(fname): """returns a list containing the last word from each line of the file."""…
Q: Write a Python function named merge_lists that takes three arguments: two lists, list1 and list2,…
A: Check if the index is within bounds of list1.If within bounds, merge list2 into list1 at the…
Q: A list cannot be passed as an argument to a function. True False
A: In programming, a list is a group of sequentially changeable elements of any data type. Most…
Q: Return Growing NumList This function will be given a single number, it should return a list of…
A: The Answer is in Below Steps
Q: Design a C++ program which reads any number of integers in a linked list until "-1" is entered. Then…
A: Here is the c++ program of the above problem. See below step for code.
Q: Write a function list2DigitOdd() that creates and returns a list that contain all positive 2-digit…
A: I have given an answer in step 2.
Q: rightspace.carleton.ca/d2l/le/content/143720/viewContent/2909861/View Problem 1 (Working with a…
A: The above question is solved in step 2 :-
Q: Help make a C++ program that: 1. Queries the user for the name of a file of text. 2. Opens the file,…
A: Algorithm processFile(filename, dWords, otherWords): 1. Open the file specified by the filename.…
Q: program7_1.pyWrite a Python program that creates a list of your friends. Start with an empty list…
A: Program:frd_list = []frdName = input('Enter the first name of a friend or ENTER to quit ')frdName =…
Q: Part B: Create letter combinations of that consist of elements of list1 and list2. For example: A,…
A: Objective: We need to design pseudocode to create two lists to store elements combining letters. Two…
Q: C Programming Language Task: Deviation Write a program that prompts the user to enter N numbers and…
A: #include <stdio.h>#include <stdlib.h>int main(){ int n; printf("How many…
Q: Write a Python program that prompts the user to enter 3 numbers, store these numbers in a list, and…
A: In this problem we need to design the code to calculate the average of the numbers. in the python…
Q: *Coding language is Python Write a program that opens the productsales.txt file and reads the sales…
A: I have provided PYTHON CODE along with CODE SCREENSHOT and also provided OUTPUT…
Q: The chapter is nested lists Create code in python using for loops Thanks!
A: A Python program for the given criteria is as follows, File name: “main.py” #Get user input…
Q: Assume my_list is a list of integer values. Write a list comprehension statement in Python that…
A: Coded using Python 3
Q: Question 1 You are given a list of characters in Harry Potter. Imagine you are Minerva McGonagall,…
A: We need to define a function called character_gryffindor() that return the names of character that…
Q: Lab Goal : This lab was designed to teach you more about list processing and algorithms. Lab D
A: Given Lab Goal : This lab was designed to teach you more about list processing and…
Q: a program that asks the user to input 2 lists of numbers, 5 numbers per y the common numbers in the…
A: Introduction of Program: The C++ program takes 5 elements in the first list and 5 elements in the…
Q: Write Python statements for the following questions 1. Define a list of 20 empty string 2. Prompt…
A: “Since you have posted a question with multiple sub-parts, we will solve the first three sub-parts…
Q: 4- Write a python program that checks if the number entered by the user is a prime number. 5- Write…
A: ****As per our guidelines i answered 2 questions.Kindly repost other questions as a separate…
Q: Integer num_reading is read from input, representing the number of integers to be read next. Read…
A: The objective of the question is to read a certain number of integers from the user input and insert…
Q: In this lab, you use what you have learned about parallel lists to complete a partially completed…
A: #Declare variablesNUM_ITEMS = 5 #Named Constant #Initialized list of add-insertaddIns =…
Q: Task 1- Random list of integers and computing the average Two functions you need to implement:…
A: Logic:- use randint from random to generate random number in range[start,end] append the generated…
Q: Write the following function that returns the location of the largest element in a two-dimensional…
A: According to the Question below the Solution: Output:
Q: Write a Python program that will construct a Linked List and will show the elements in the list. The…
A: In this question we have to write a python program that will construct a linked list and will show…
Q: 4 Generalized Printing You are tasked with creating generalized list printing functions. Write a…
A: Algorithm:Define the printGenList function that takes a list lst and a printing function f as…
Q: Create a list L containing at least 10 values ranging from j to k. Using a for loop, code a function…
A: Since no programming language is mentioned, I am using python. Algorithm: Start Initialize list L…
Q: #include #include #include #include "stack.h" /* Checks whether the parenthesis in str are…
A: Actually, program is a executable software that runs on a computer.
Q: Write a program that prompts the user for floating-point numbers until the user enters the word…
A: I have given an answer in step 2.
Step by step
Solved in 3 steps with 3 images
- Python 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…Lottery number generator: Write a program that generates aseven-digit lottery number. The program should have a loopto generate seven random numbers, each in the range 0through 9 and assign each number to a list element.2. Write another loop to display the contents of the list.3. Tip: You will need to create/initialize your list before you canassign numbers to it.4. Use program 7-1 sales_list as an example. You will start witha seven-digit lottery number that contains all zeros. Then inyour loop, you will assign a random number instead ofgetting the data from the user.Turn in your program to the practice assignment link in coursecontent.1 # MichiganCities.py - This program prints a message invalid cities in Michigan. Summary 2 # Input: Interactive 3 # Output: Error message or nothing In this lab, you use what you have learned about searching a list to find an exact match to 4 complete a partially prewritten Python program. 5 # Initialized list of cities 6 citiesInMichigan = ["Acme", "Albion", "Detroit", "Watervliet", "Coloma", "Saginaw", "Richland", "Glen "Midland", "Brooklyn"] The program uses a list that contains valid names for 10 cities in Michigan. You ask the user to enter a city name; your program then searches the list for that city name. If it is not found, the 7 program should print a message that informs the user the city name is not found in the list of valid 8 # Get user input cities in Michigan. 9 inCity = input ("Enter name of city: ") 10 11 The starter file provided for this lab includes input statements. You need to write code to examine 12 # Write your test statement here to see if there is all the…
- statistics.py: Write a program that reads a list of integers from the user, until they enter -12345 (the -12345 should not be considered part of the list). Then print the mean, median, and standard deviation of the list. The mean is the average of the numbers. The median is the “middle” value if n is odd, or the average of the two “middle” values if n is even. The standard deviation is the average amount of variability For example: $ python3 statistics.py154102-12345mean: 7.75median: 7standard deviation: 5.909032633745278public List<String> getLikes(String user) This will take a String representing a user (like “Mike”) and return a unique List containing all of the users that have liked the user “Mike.” public List<String> getLikedBy(String user) This will take a String representing a user (like “Tony”) and return a unique List containing each user that “Tony” has liked. create a Main to test your work. import java.io.BufferedReader;import java.io.FileReader;import java.io.IOException;import java.util.ArrayList;import java.util.Arrays;import java.util.HashMap;import java.util.HashSet;import java.util.List;import java.util.Map;import java.util.Set; public class FacebookLikeManager { public List<String> facebookMap; private Set<String> likesSets; public FacebookLikeManager() { facebookMap = new ArrayList<>(); likesSets = new HashSet<>(Arrays.asList("Mike","Kristen","Bill","Sara")); } public void buildMap(String filePath) {…Contact list: Binary Search A contact list is a place where you can store a specific contact with other associated information such as a phone number, email address, birthday, etc. Write a program that first takes as input an integer N that represents the number of word pairs in the list to follow. Word pairs consist of a name and a phone number (both strings). That list is followed by a name, and your program should output the phone number associated with that name. Define and call the following function. The return value of FindContact is the index of the contact with the provided contact name. If the name is not found, the function should return -1 This function should use binary search. Modify the algorithm to output the count of how many comparisons using == with the contactName were performed during the search, before it returns the index (or -1). int FindContact(ContactInfo contacts[], int size, string contactName) Ex: If the input is: 3 Frank 867-5309 Joe 123-5432 Linda…
- in pythonclass SpecialList: """A list that can hold a limited number of items.""" def __init__(self, size: int) -> None: """Initialize this special list to hold at most size items. >>> L = SpecialList(10) >>> L.size 10 >>> L.value_list [] """ # complete the code def push_value(self, new_value: object) -> None: """Append new_value to this list, if there is enough space in the list according to its maximum size. If there is insufficient space, new_value should not be added to the list. >>> L = SpecialList(2) >>> L.push_value(3) >>> L.push_value(4) >>> L.push_value(5) >>> L.value_list [3, 4] """ # complete the code def pop_most_recent_value(self) -> object: """Return the value added most recently to value_list and remove it from the list.…Yahtzee! Yahtzee is a dice game that uses five die. There are multiple scoring abilities with the highest being a Yahtzee where all five die are the same. You will simulate rolling five die 777 times while looking for a yahtzee. Program Specifications : Create a list that holds the values of your five die. Populate the list with five random numbers between 1 & 6, the values on a die. Create a function to see if all five values in the list are the same and IF they are, print the phrase "You rolled ##### and its a Yahtzee!" (note: ##### will be replaced with the values in the list) Create a loop that completes the process 777 times, simulating you rolling the 5 die 777 times, checking for Yahtzee, and printing the statement above when a Yahtzee is rolled. When you complete the project please upload your .py file to the Project 2 folder by the due date.