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 is NOT one of the OWASP Top 10 web security risks?
- What is the primary function of Network Address Translation (NAT)?
- Which concept in virtual machines allows multiple operating systems to share the same hardware resources while remaining isolated from each other?
- Which component of a Management Information System (MIS) focuses on long-term strategic planning?
- Which of the following statements correctly describes a major difference between public and private clouds?
- Which design pattern would you use if you need to ensure that a class has only one instance, with a global point of access to that instance?
- In data analytics, which algorithm is commonly used for predictive modeling when the target variable is categorical?
- Which of the following best describes the IaaS model?
- In computer fundamentals, what is the primary purpose of the BIOS in a computer system?
- Given the IP address block 192.168.0.0/24, how many subnets can be created by borrowing 2 bits from the host portion, and what will be the new subnet mask?...
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)