Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
127 views

Mod 2 Functions

The document outlines tasks for a Python developer to create classes with methods and functions, including inheriting behaviors from a parent class and encapsulating data. Developers are instructed to define functions that print messages, create methods that take arguments, write a function to sum user inputs in a loop, and use a constructor and additional functions to encapsulate a variable value.

Uploaded by

V P
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
127 views

Mod 2 Functions

The document outlines tasks for a Python developer to create classes with methods and functions, including inheriting behaviors from a parent class and encapsulating data. Developers are instructed to define functions that print messages, create methods that take arguments, write a function to sum user inputs in a loop, and use a constructor and additional functions to encapsulate a variable value.

Uploaded by

V P
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Python for Data Science Certification Course

Module 2: Functions Assignment

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.

5. Create a class named ‘Encapsulation’:

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.

support@intellipaat.com - +91-7022374614 - US: 1-800-216-8930 (Toll Free)

You might also like