Write a program in C++ which gives the user a list as :follows Even numbers -1 Odd numbers -2 Exit -3
Q: Write a Python program to create a doubly-linked list. Append some items on the doubly-link list.…
A: Here, I have to provide a python code to the following question based on the given reference.
Q: In Python IDLE: How would I transform this list [2,4, 3, 7,8] into a list of list as below [[2],…
A: Here I have created the list having numbers. Next, I have iterated over the list using for loop.…
Q: Write a C program by using the Singly Linked List technique that will take an integer value as input…
A: Below is the program implementation of above in C language. NOTE: To remove second last, one utility…
Q: Write a Python program that takes two lists and prints True if they have at least one common member.
A: Answer : def common_data(list1, list2): result = False for x in list1: for y…
Q: Write a function in SCALA language to take a list I and a number n as a parameter and returns a list…
A: Write a function in SCALA language to take a list l and a number n as a parameter and returns a list…
Q: 5. In Python language, write a program to remove all negative elements from the list given below.…
A: Above question can be solved using simple list comprehension of python
Q: Write a function in C++ that takes a list as input and prints all the unique values in the array…
A: Task :- Write a C++ program to print unique values in the array only once. C++ code :- #include…
Q: Write a Python code for the given functions and definitions: Task1 Given function: def…
A: Task1: PROGRAM CODE: # Python code to check for empty list# Explicit waydef isEmpty(lis1): if…
Q: Write a C++ program that prompts the user to enter a list of words and stores in a list only those…
A: We need to write a C++ program that takes the List of words as input from the user and stores only…
Q: Write a program in C++ that reads the list from a file and do the rotation
A: Algorithm Needs to perform a left rotation on a variety of components. Specifically, std::rotate…
Q: Write a c++ program read N numbers. Then find the numbers in the list, whose summation of three…
A: Intorduction: This is a coding question, need to print three numbers whose sumamtion exists in the…
Q: Write a program in C++ that asks the user to input 2 lists of numbers, 5 numbers per list. Your…
A: Introduction of Program: The C++ program takes 5 elements in the first list and 5 elements in the…
Q: Given a list, write a C++ program to print mirror of that list.
A: Input : Input list in C++. Output : Print mirror of input list i.e. list in reverse order.
Q: Write a function that will duplicate every list element using recursion. Example: List: ['I',…
A: Based on Python
Q: Write a lisp function f9 that removes duplicates from a list. Example: (f9 ‘(c (a b) c d (a b)))…
A: The answer is given below:-
Q: In Python Use the Design Recipe to write a function, print_histogram that consumes a list of…
A: Programming Instructions: Define the function print_histogram which takes the list of integers as…
Q: Write a program in C++ that will let the user input a string and with the use of a singly linked…
A: C++ language is a direct descendant of C programming language with additional features such as type…
Q: Question: Write a python program that will take a sentence as an input from the user where each word…
A: Define variable sentence and take user input in it Define empty array novowels Use split function to…
Q: Using the Scheme dialect of Lisp, write a single function that squares each item of a list, then…
A: Using Schemes (Sub: Programming Language) It a minimalist dialect of the Lisp family of programming…
Q: What is the major difference between tuples and lists in Python?
A: Question. What is the major difference between tuples and lists in Python? Answer. The major…
Q: Write a program in c++ which reads a list of ten numbers and prints the list in reverse order.…
A: #include<iostream> using namespace std; class Reverse { private : int arr[10]; public:…
Q: Write a PYTHON function (program) that takes a list as argument, and returns its first element.
A: Coded using Python 3.
Q: Write a PYTHON function (program) that takes two arguments, an element and a list and returns a list…
A: EDITABLE CODE: def program(element,ls): ls.insert(0,element) return lselement=int(input("Enter…
Q: Write a C++ program in which a list data structure is declared and 10 random numbers are inserted…
A: Here have to determine about c++ code for element of array with rand().
Q: 2. Write a complete Java program that provides two methods named sort(list) and filter(list). a.…
A: import java.util.ArrayList;import java.util.List;import java.util.Scanner;import…
Q: In Python, what is the main difference between tuples and lists?
A: Answer. The major difference between tuples and lists in Python are given below:
Q: Write a program in C++ that will let the user input a string and with the use of a singly linked…
A: Here is the C++ program: #include <iostream> #include<bits/stdc++.h>using namespace std;…
Q: What is the correct way to get minimum value from a List in Python? give an example
A: Programs are used to perform specific tasks, built or develop certain applications, projects, or…
Q: ease don't copy Write a lisp function f4 that returns the maximum value of an integer list. Example:…
A: Given Please don't copy Write a lisp function f4 that returns the maximum value of an integer…
Q: Write a function in C++ that adds two nodes at the end of the singly link list Like add two nodes…
A: Disclaimer: “Since you have asked multiple questions, we will solve the first question for you. If…
Q: A list of int values can be defined recursively as: a list item, a comma, and a list, where a list…
A: Defined the given statement true or false
Q: Write a program in C Language that stores polynomials into Doubly Linked List and add a function to…
A: Hey there, I am writing the required solution based on the above given question. Please do find the…
Q: writing a code on the difference between string vs lists vs Dictionaries in Python
A: Actually, python is a easiest programming language. It is dynamically typed programming language.
Q: Write a C program that reads polynomials from file and stores them into doubly linked list.
A: While doing programming in any programming language, you need to use various variables to store…
Q: Write a program in C language to create a singly linked list as shown below and print it in the…
A: Write a program in C language to create a singly linked list as shown below and print it in the…
Q: In Python: Write a function that takes in two lists (A and B) as parameters, and an integer (sum).…
A: Given data, Write a function that takes in two lists (A and B) as parameters, and an integer (sum).…
Q: write a c++ program that prints the first and last number in a list using a while loop
A: // Program to find first and last// digits of a number#include <bits/stdc++.h>using namespace…
Q: Write a Python program to concatenate the given list into a single list without using extend method.…
A: Required:- Write a Python program to concatenate the given list into a single listwithout using…
Q: write a c++ program using double linked list in which we create a library managment system. Program…
A: C++ program for Library management First we insert the book details like title, year, publisher.…
Q: Write a program in C++ that first gets a list of integers from input. The input begins with an…
A: A C++ program is given below, File name: “main.cpp” //Declare the header files #include…
Q: Write a program in C which will swap any two numbers on a circular linked list.
A: #include <stdio.h> #include <string.h> #include <stdlib.h> //Represents the…
Q: Write a program in python language in which you have to print the length of list using iterative…
A: Requirements :- Write a program in python language in which you have to print the length of list…
Q: Write a list comprehension and its equivalent lambda function for the Python code shown below.…
A: In step 2, you will get python code using lambda. In step 3, you can see the output.
Q: In lisp, what is the program to return yes if an item n is followed immediately by item m in a…
A: Answers package queueQuestions; import java.util.ArrayList; import java.util.List; public class…
Q: Write a program in haskell programming language to find the product of list elements formed in O(1)…
A: Requirements:- Write a program in Haskell programming language to find the product of list elements…
Q: Write a C program that asks a name from the user and arranges the names alpabetically using linked…
A: GIVEN: Write a C program that asks a name from the user and arranges the names alphabetically…
Q: Here is a data type definition for a list in Haskell: data List a = Empty | One a | Append (List a)…
A: Here is a data type definition for a list in Haskell: data List a = Empty | One a | Append (List a)…
Q: Write a LISP function f10 that finds the intersection of two lists. The intersection means the…
A: (defun f10 (lst-a lst-b &aux result) (dolist (a lst-a (nreverse result)) (dolist (b lst-b)…
Q: Consider the following program written in C syntax: void fun (int first, int second) { first +=…
A: In programming languages such as C, when the function is called from the main() it is either passed…
c++ program
Step by step
Solved in 2 steps with 1 images
- Write a python program that reads the first n lines of a text file. Suppose you have a file with all these strings in a file. ========================================================= I love Python Programming.It is very easy to understand the code.It can code very hard problems easily in python code.Python programming is the best programming language. ========================================================= Input :2Output :I love Python Programming.It is very easy to understand the code. ========================================================= Hint(1):Use counter to control line number. Hint(2):Use function readlines() to store in a list and then use loop OR you can use readline() in a loop. Hint(3):You might need to use strip() functionWrite a python program that contains a function called filereader() that takes a number n (int) and filename (string) as input. The function should read and store every nth line of the file in a list. The function should return the list Test your function using the main function (don’t forget the main guard).Example:File:kangaroocapybarawombatkoalawallabyquokkaplatypusdingokookaburra n: 3output:wombatquokkakookaburra Hint: The problem should help you practice file io, specifically reading files and basic algorithmdesign.Write a python program that contains a function called filereader() that takes a number n (int) and filename (string) as input. The function should read and store every nth line of the file in a list. The function should return the list. Test your function using the main function (don’t forget the main guard). Example:File:kangaroocapybarawombatkoalawallabyquokkaplatypusdingokookaburra n: 3output:wombatquokkakookaburra
- Write 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 languageWrite a Python program that prompts the user to enter a list of words and stores in a list only those words whose first letter occurs again within the word (for example, 'Baboon'). The program should display the resulting list. NOTE: 'Baboon' starts with a capital letter and should be included in the list (therefore, the test is not case-sensitive). When you print the word list, ensure you maintain case-sensitivity; i.e. Both 'Baboon' and 'baboon' should be in the list that prints out, if they were provided as input by the user.Please write a program that checks if the last data item entered appears earlier in the list. The input is a sequence of non-negative numbers, which is terminated by a user entering a -1. The code needs to output ONLY ONE of these 3 messages: Yes the last data item appears earlier, No the last data item appears earlier, No Data Provided The code is also not allowed to compare the last number with itself. Thanks!
- Write a python program that does the following: Reads information from a text file into a list of sublists. Be sure to ask the user to enter the file name and end the program if the file doesn’t exist. Text file format will be as shown, where each item is separated by a comma and a space:ID, firstName, lastName, birthDate, hireDate, salary Store the information into a list of sublists called empRoster. EmpRoster will be a list of sublists, where each sublist contains the information for one employee.The birthDate and hireDate in file are strings, but should be stored as objects of type Date.Example of EmpRoster list with 2 employees:[ [111,”Joe”, “Jones”, “09-01-1980”,”10-19-1999”, 95000], \ [222, “Sam”, “Smith”, “07-10-1956”,, “01-01-2000”, 50000] ] Print a report that shows the following: Employee RosterID First Name Last Name Birth Date Age Hire Date YrsWorked Salary WRITE the following information out to a…In Python, Ask the user to enter a sentence,e.g., Computer Science is awesom. Pass the sentence to a function str2words() and convert the string/sentence into words; place individual words,e.g., 'Computer', 'Science', etc. into a list and return the list to main program. In addition, the individual words should not contain any whitespaces appended to the end of the word such as 'Science'. Do not use any built-in functions to convert a string to words.In c programe please (c#) 7.18 LAB: Output values below an amount Write 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: 5 50 60 140 200 75 100 the output is: 50,60,75, 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.
- Please answer it in Python Write a function indice_de that takes as an argument an integer (supposedly even) and a list, and returns the index to which this integer appears in the list. If the integer does not appear, the function will return None. It is assumed here for simplicity that the integer searched for does not appear several times in the list. Hint: if the for e in list loop doesn't suit you, remember that you can make a for + range or a while. .. Example: indice_de(12, [4, 7, 12, 0, 21, 5]) return => 2 (because 12 is placed at index 2), and indice_de(6, [4, 7, 12, 0, 21, 5]) return => None. Write a function trouve_premier_pair that takes a list as an argument and returns the even integer that appears first in the list. If the list does not contain an even integer, the function will return None. Example: trouve_premier_pair([1, 15, 4, 7, 12, 3]) return =>4 and trouve_premier_pair([1, 17, 7]) return =>None. Write a function extrait_even that takes as an…Write a function named mostCharacters that takes a list of strings as an argument and a character as an argument. It then returns the string within the list that contains the highest count of the character. (If there is a tie for the highest count, return a list of all the strings) (IN PYTHON) For example, if you run mostCharacters(["cherry", "tomato", "salad", "shrimp"], 'r') it will return "cherry" If you run mostCharacters(["cherry", "tomato", "salad", "shrimp"], 's') it will return ["salad", "shrimp"] (IN PYTHON)The function last_words in python takes one parameter, fname, the name of a text file, and returns a list containing the last word from each line of the file. For example, if the file contents are: apples are red bananas are yellow limes are green then the list ["red", "yellow", "green"] should be returned. NOTE: You may assume the file will contain no blank lines. BIG HINT: If line is a string representing a line of text (inside a for loop!), then L = line.split() creates a list of the words in the line. For example: Test Result L = last_words("wordlist1.txt") print(L) ['happy', 'sad', 'angsty', 'euphoric', 'maudlin']