Module 2 - File 1-Hands-On
Module 2 - File 1-Hands-On
+91-7022374614
Tasks to be performed:
1. Create a function named ‘factor’ that can only accept 1 argument. The function should
return the factorial of that number.
2. Create a function named ‘check_string’, the function should accept a string data from the
user and the function should check if the user input contains the letter ‘s’ in it. If it contains
the letter ‘s’ then print- ‘The string is containing the letter ‘s’’, if not then print- ‘The string
doesn’t contain the letter ‘s’’.
3. Create a class named ‘student’ and inside the class, create a function named ‘fun1’- this
method should accept the user defined input and return that value.
a. Create another method named- message() and that method should print the user
defined input that we have defined in ‘fun1’.
4. Create a lambda function that should double or multiply the number (that we will be passing
in the lambda function) by 2. Store the lambda function in a variable named ‘double_num’.
5. Take the user input string and check whether that string is palindrome or not.
6. 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.
7. Create another class 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().
8. Create 2 methods named ‘Hello’. In the 1st Hello method, pass only one argument and pass
this message: ‘This function only has 1 argument’. And in the 2nd Hello method, pass
two arguments and pass this message: ‘This function has 2 arguments’.
a. Try to call both the methods and analyze the output of both the methods.
9. 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.
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 the newValue variable.