Question
What will be the output of the following code when printList is called with a linked list containing the values 1 -> 2 -> 3? class Node: def __init__(self, data): self.data = data self.next = None class LinkedList: def __init__(self): self.head = None def append(self, data): new_node = Node(data) if not self.head: self.head = new_node return last_node = self.head while last_node.next: last_node = last_node.next last_node.next = new_node def printList(self): current = self.head while current: print(current.data, end=" -> ") current = current.next print("None") ll = LinkedList()
What will be the output of the following code when printList is called with a linked list containing the values 1 -> 2 -> 3? class Node: def __init__(self, data): self.data = data self.next = None class LinkedList: def __init__(self): self.head = None def append(self, data): new_node = Node(data) if not self.head: self.head = new_node return last_node = self.head while last_node.next: last_node = last_node.next last_node.next = new_node def printList(self): current = self.head while current: print(current.data, end=" -> ") current = current.next print("None") ll = LinkedList()
ll.append(1)
ll.append(2)
ll.append(3)
ll.printList()
More Basics of Computers Questions
- Which of the following statements correctly describes a major difference between public and private clouds?
- Which phase of the Software Development Lifecycle (SDLC) focuses on identifying the feasibility and goals of the project?
- Which of the following best describes the main advantage of a Management Information System (MIS)?
- Data Analytics uses ___ to get insights from data.
- Which of the following best describes the role of digital signatures in ensuring security in digital communications?
- What will be the output of the following JavaScript code when executed? let xhr = new XMLHttpRequest(); xhr.open("GET", "https://api.example.com/data", fal...
- In systems design, which of the following techniques is used to break down complex systems into smaller, more manageable components?
- What type of firewall inspects packets and determines whether they are allowed based on pre-established rules?
- What will be the output of the following Java code snippet, which implements a simple ArrayList and performs an insertion and a retrieval? import java.u...
- Which of the following is a primary advantage of using a private cloud?
Relevant for Exams:
Hey! Ask a query
Please enter email id
The email must be a valid email address.
Please enter Mobile Number
Please enter valid Mobile Number
Please enter your Doubt
Think You're Ready for RBI Grade B?
RBI Grade B 2026 Phase 1 Memory Based Paper
- 200 Questions with Detailed Solutions
- Section-wise Coverage (GA, English, Quant & Reasoning)