Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Hello I want to write All my outcomes into the outcome.txt and keep appending to that but idk how to add that into my current
Hello I want to write All my outcomes into the "outcome.txt" and keep appending to that but idk how to add that into my current code. Can someone help me pls? I put my main function
main.py
# importing files import linkedlist as LL import queue as Q import stack as S import money as M import random # main function definition def main(): LinkedList_tests() Stack_tests() Queue_tests() # definition of all the test methods def create_test_data(): data = [] # Create seven (7) Node objects of Money class to be used in the program. for i in range(7): amount = random.randint(1, 100) m = M.Money(amount) data.append(m) return data def LinkedList_tests(): print("Linked List tests") data = create_test_data() L = LL.SinglyLinkedList() L.add_to_front(data[0]) print(str(L)) L.add_to_front(data[1]) print(str(L)) L.add_to_end(data[2]) print(str(L)) print("The number at the front of the list: " + str(L.get_front_data())) print("The number at the end of the list: " + str(L.get_end_data())) L.delete_from_front() print(str(L)) L.add_to_end(data[3]) print(str(L)) print("count = " + str(L.get_count())) print("_" * 50) def Stack_tests(): print("Stack tests") s = S.Stack() data = create_test_data() s.push(data[0]) print(s) s.push(data[1]) s.push(data[2]) print(s) s.pop() print(s) print("The number at the front of the list:", s.peek()) print("The number at the end of the list:", s.count()) print("Is the file empty?", s.is_empty()) print("_" * 50) def Queue_tests(): print("Queue tests") q = Q.Queue() data = create_test_data() q.enqueue(data[0]) print(q) q.enqueue(data[1]) print(q) q.enqueue(data[2]) print(q) q.dequeue() print(q) print("Is the file empty?", q.is_empty()) print("The number at the front of the list:", q.peek_front()) print("The number at the end of the list:", q.peek_end()) # calling main main()
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started