Computer Science With Python Chapter 6 Stacks & Queues In List
  • Sponsor Area

    NCERT Solution For Class 12 Computer And Communication Technology Computer Science With Python

    Stacks & Queues In List Here is the CBSE Computer And Communication Technology Chapter 6 for Class 12 students. Summary and detailed explanation of the lesson, including the definitions of difficult words. All of the exercises and questions and answers from the lesson's back end have been completed. NCERT Solutions for Class 12 Computer And Communication Technology Stacks & Queues In List Chapter 6 NCERT Solutions for Class 12 Computer And Communication Technology Stacks & Queues In List Chapter 6 The following is a summary in Hindi and English for the academic year 2021-2022. You can save these solutions to your computer or use the Class 12 Computer And Communication Technology.

    Question 1
    CBSEENCO12011593

    Evaluate the following Postfix notation of expression:
    4,2,*,22,5,6,+,/,-

    Solution
    Element Stack Contents  
    4 4
    2 4,2
    * 8
    22 8, 22
    5 8, 22, 5
    6 8, 22, 5, 6
    + 8, 22, 11
    / 8, 2
    - 6
    Question 2
    CBSEENCO12011594

    Differentiate between file modes r+ and rb+ with respect to Python.

    Solution

    Difference b/w r+ and rb+ with respect to Python

    r+   rb+ 
    r+ Opens a file for both reading and writing. The file pointer placed at the beginning of the file. rb+ Opens a file for both reading and writing in binary format. The file pointer placed at the beginning of the file.
    Question 3
    CBSEENCO12011641

    Evaluate the following postfix notation of expression. Show status of the stack after every operation.
    22,11,/,14,10,,+,5,2

    Solution
    Element Stack
    22 22
    11 22, 11
    / 2
    14 2,14
    10 2,14,10
    - 2,4
    + 6
    5 6,5
    - 1    
    Question 5
    CBSEENCO12011643

    Write a method in python to write multiple line of text contents into a text file myfile.txt line.

    Solution
    Numbers=[9,18,27,36]
    def writel():
    	f = open('myfile.txt','w')
    	while True:
    		line = raw_input('Enter line')
    		f.write(line)
    		choice = raw_input('Are there more lines')
    		if choice == 'N':
    			break
    	f.close()
    `
    Question 7
    CBSEENCO12011691

    Write PUSH (Books) and POP (Books) methods in python to add Books and remove Books considering them to act as Push and Pop operations of Stack.

    Solution
    def push(Books):
    	Stack.append(Books)
    	print 'Element:', Book, 'inserted successfully'
    def pop():
    	if Stack == []:
    		print('Stack is empty!')
    	else:
    		print('Deleted element is',Stack.pop())
    Question 8
    CBSEENCO12011692

    Write a method in python to find and display the prime numbers between 2 to N. Pass N as an argument to the method.

    Solution
    def prime_numbers(N):
    	for I in range(2, N+1):
    		M = I // 2
    		IsPrime=1
    	for J in range(2, M+1):
    		if I % J == 0:
    			IsPrime=0
    			break
    		if IsPrime==1:
    			print(I)
    Question 9
    CBSEENCO12011693

    Evaluate the following postfix notation of expression. Show status of the stack after every operation.
    84, 62, –, 14, 3, *, +

    Solution

    Stack status of every operation is given below:

    Element Stack
    84 84
    62 84,62
    - 22
    14 22,14
    3 22, 14, 3
    * 22, 42
    + 64

    Mock Test Series

    Sponsor Area

    Sponsor Area

    NCERT Book Store

    NCERT Sample Papers

    Entrance Exams Preparation

    14