Posts

Showing posts from February, 2022

Application Development using Python (18CS55) VTU Questions and Solutions - 3

1.  What is class, object. Explain copy.copy() with an example code. A class is a user-defined blueprint or prototype from which objects are created. 2Marks An Object is an instance of a Class. A class is like a blueprint while an instance is a copy of the class with actual values.   Copying an object is often an alternative to aliasing. The copy module contains a function called copy that can duplicate any object: p1 = Point() p1.x = 3.0 p1.y = 4.0 import copy p2 = copy.copy(p1) p1 and p2 contain the same data, but they are not the same Point. print_point(p1) (3, 4) print_point(p2) (3, 4) p1 is p2 False 2.   Demonstrate pure functions and modifiers with example codes A pure function because it does not modify any of the objects passed to it as arguments and it has no effect, like displaying a value or getting user input, other than returning a value. Example code (3 Marks)   def add_time(t1, t2):     sum = Time()     sum.hour = t1.ho...

Application Development using Python (18CS55) VTU Questions and Solutions - 2

 1.   Explain in and not operator in string with suitable examples. Ans : in and not in are membership operators. in operator. The in operator in Python checks whether a specified value is a constituent element of a sequence like string, array, list, or tuple etc. When used in a condition, the statement returns a Boolean result evaluating into either True or False. When the specified value is found inside the sequence, the statement returns True. Whereas when it is not found, we get a False. The ‘not in’ operator is the complement of in. [02] a in  calendar                    z in calendar       a not in calendar       z not in calendar True                                 False                   False          ...