# cannot contain syntax error
# stack class
class Stack:
def __init__(self, iL=[]):
self.aList = iL[:]
def push(self, newElem:int):
"""push a new element on top"""
self.aList.append(newElem)
def pop(self)->int:
"""return top item"""
return self.aList.pop()
def empty(self):
"""Is the stack empty?"""
return self.aList == []
def __repr__(self):
return repr(self.aList)
# use only the above stack methods to define a function to
# delete an item x from a stack, (only one x (the upper one) is to be deleted)
# keep the order of the remaining items in the stack unchanged
# can change orginal stack
# return a new stack
def delx(sk:Stack, x:'item')-> Stack:
#Code goes here
if __name__ == "__main__":
#Testing code here
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps with 1 images
- Given a chess board, your job is to write a program that takes two squares x and y as input and then determines the number of knight moves on a shortest route from x to y. a b c d e f g h 8 e2 e4 al b2 b2 c3 al h8 al h7 h8 al b1 c3 f6 f6 7 6 01 5 4 3 2 1 T ● a b c d e f g h 8965 4 2 7 3 1 Input Specification Your program should read from an input file, which will contain one or more test cases. Each test case consists of one line containing two squares separated by one space. A square is a string consisting of a letter (a-h) representing the column and a digit (1-8) representing the row on the chessboard. Sample Inputarrow_forwardimport 'dart:io';import 'module.dart';List<Module> modules = [];void main() {int? choice = 1;while (choice != 5) {choice = menu();if (choice != null && choice >= 1 && choice <= 5) {switch (choice) {case 1:createFromExisting();break;case 2:printModuleData();break;case 3:changeWeights();break;case 4:printAverageOfClass();break;}} else {print('Invalid choice, please choose again');choice = -1;}}print('Good bye!');}void createFromExisting() {//30 marks//This method retrieves the data from the TPG316C.csv file to create a new Module////Steps://1. Ask the user to enter a name for the new module//2. Read the name//3. Ask the user to enter the name of the file to read module data from (we will use TPG316C.csv)//4. Read the name of the file//5. Read the lines from the file into a List<String>//6. Create a new Module instance with empty fields, except for the name of the Module//7. Use the first element in the List<String> created in step 5 to extract the…arrow_forward#ifndef LLCP_INT_H#define LLCP_INT_H #include <iostream> struct Node{ int data; Node *link;};void DelOddCopEven(Node*& headPtr);int FindListLength(Node* headPtr);bool IsSortedUp(Node* headPtr);void InsertAsHead(Node*& headPtr, int value);void InsertAsTail(Node*& headPtr, int value);void InsertSortedUp(Node*& headPtr, int value);bool DelFirstTargetNode(Node*& headPtr, int target);bool DelNodeBefore1stMatch(Node*& headPtr, int target);void ShowAll(std::ostream& outs, Node* headPtr);void FindMinMax(Node* headPtr, int& minValue, int& maxValue);double FindAverage(Node* headPtr);void ListClear(Node*& headPtr, int noMsg = 0); // prototype of DelOddCopEven of Assignment 5 Part 1 #endifarrow_forward
- Data Structures/Algorithms in Javaarrow_forwardWhat happens when a programmer attempts to access a node's data fields when the node variable refers to None? How do you guard against it? *PYTHONarrow_forward1 Assume some Node class with info & link fields. Complete this method in class List that returns a reference to the node containing the data item in the argument find This, Assume that find this is in the list public class List { protected Node head; protected int size; fublic Public Node find (char find This)arrow_forward
- Question 10 (1 point) ListenReadSpeaker webReader: Listen Given the following code, assume the myStack object is a stack that can hold integers and that value is an int variable.1 myStack.push(0);2 myStack.push(1);3 myStack.push(2);4 myStack.pop(value);5 myStack.push(3);6 myStack.pop(value);7 Console.WriteLine(value);Assume that the pop function, called on lines 4 and 6, stores the number popped from the stack in the value variable. What will the statement on line 7 display? Question 10 options: a) 0 b) 3 c) 2 d) 1arrow_forwardGiven the following code, assume the myQueue object is a queue that can hold integers and that value is an int variable.1 myQueue.enqueue(0);2 myQueue.enqueue(1);3 myQueue.enqueue(2);4 myQueue.dequeue(value);5 Console.WriteLine(value);Assume that the dequeue function, called on line 4, stores the number removed from the queue in the value variable. What will the statement on line 5 display? Question 43 options: a) 2 b) 0 c) 1 d) none of thesearrow_forwardCreate a view, using JOBS, DEPARTMENTS, and JOB_HISTORY tables that will include department name (not ID), job title (not jobID), start date, and end date for all rows in the JOB_HISTORY table Using your view, write a query that shows the number of rows (count) for each department. Write a query that uses your view from above to select the columns department name, job title, and end date for all rows where the department name includes the string “Sale” that is NOT case-sensitive. Use a function. i.e. SALE, SaLe, Sale, sAle, etc. should all match a rowarrow_forward
- 1.Assume some Node class with info link fields . Complete this method in class List that returns a reference to the node containing the data item in the argument findThis, Assume that findThis is in the list public class list { protected Node head ; Protected int size ; Public Node find (char find this) { Node curr = head; while(curr != null) { if(curr.info == findThis) return curr; curr = curr.link; } return -1; } }arrow_forwardStack: Stacks are a type of container with LIFO (Last In First Out) type of working, where a new element is added at one end and (top) an element is removed from that end only. Your Stack should not be of the fixed sized. It should be able to grow itself. bool empty() : Returns whether the Stack is empty or not. Time Complexity should be: O(1) bool full() : Returns whether the Stack is full or not. Time Complexity should be: O(1)int size() : Returns the current size of the Stack. Time Complexity should be: O(1)Type top () : Returns the last element of the Stack. Time Complexity should be: O(1) void push(Type) : Adds the element of type Type at the top of the stack. Time Complexity should be: O(1) Type pop() : Deletes the top most element of the stack and returns it. Time Complexity should be: O(1) Write non-parameterized constructor for the above class. Write Copy constructor for the above class. Write Destructor for the above class. Now write a global function show stack which…arrow_forwardInterval Difference: Please help me with this assertion errorarrow_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