Computer Science With Python Chapter 8 Exception Handling & Generate Functions
  • Sponsor Area

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

    Exception Handling & Generate Functions Here is the CBSE Computer And Communication Technology Chapter 8 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 Exception Handling & Generate Functions Chapter 8 NCERT Solutions for Class 12 Computer And Communication Technology Exception Handling & Generate Functions Chapter 8 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
    CBSEENCO12011544

    Write Addnew(Book) and Remove(Book) methods in Python to Add a new Book and Remove a Book from a List of Books, considering them to act as PUSH and POP operations of the data structure Stack.

    Solution
    class stack:
    	Book=[]
    	def Addnew(self):
    		Name=input('Enter Book Name :')
    		stack.Book.append(Name)
    	def Remove(self):
    		if (stack.Book==[]):
    			print 'Stack Empty'
    		else:
    			print 'Deleted Book is : ',stack.Book.pop()
    Question 3
    CBSEENCO12011547

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

    Solution

    Difference between r+ and w+ is  given below:
    r+ Opens a file for both reading and writing. The file pointer placed at the beginning of the file.
    w+ Opens a file for both writing and reading. Overwrites the existing file if the file exists. If the file does not exist, creates a new file for reading and writing.

    Mock Test Series

    Sponsor Area

    Sponsor Area

    NCERT Book Store

    NCERT Sample Papers

    Entrance Exams Preparation

    31