Mod 2 Functions
Mod 2 Functions
Problem Statement:
You work in XYZ Corporation as a Python Developer. Your corporation have told your to work
with the methods, and functions in Python.
Tasks to be performed:
1. Create a class named ‘Super’ and inside that class define a user-defined function named
fun1.
a. Inside the ‘fun1’ function, pass the message “This is function 1 in the Super class.”
in the print statement.
2. Create another classed named ‘Modified_Super’ and inherit this class from the Super class.
a. Inside the Modified_Super class, create a function named ‘fun1’ and pass the
following message inside the print statement: ‘This is function 1 in the Modified
Super class.’
b. Create another user-defined function named ‘fun2’ and pass the message: ‘This is
the 2nd function from the Modified Super class’ in the print statement.
c. After that, now create an object for the Modified_Super class and call the fun1().
3. Create 2 methods named ‘Hello’. In the 1st Hello method, pass only one argument and pass
this message: ‘This function is only having 1 argument’. And in the 2nd Hello method, pass
two arguments and pass this message: ‘This function is having 2 arguments’.
a. Try to call both the methods and analyze the output of both the methods.
4. Create a method named ‘Sum’ that can accept multiple user inputs. Now add those user-
defined input values using for loop and the function should return the addition of the
numbers.
a. Inside the class, first create a constructor. Inside the constructor, initialize
originalValue variable as 10.
b. After creating the constructor, define a function named ‘Value’ and this function
should return the variable that we have initialized in the constructor.
c. Now create 2nd function named setValue, and pass an argument named
‘newValue’. The task of this function will be to replace the value of the
originalValue variable by the value of newValue variable.