Python Practice on Parameters Inheritance

In this class, we do python practice on parameters inheritance.

For Complete YouTube Video: Click Here

Example 1

The examples discussed will help in improving coding skills.

These placement training examples give you a deeper understanding of the concepts of python.

Check the questions given below and try to solve them on your own. That is the best practice.

Q1) Check the program given below and identify the output displayed by the program.

Python Practice on Parameters Inheritance1
Program 1

In the above program, they are asking the value stored in variables arg1 and arg2.

They are trying to check your understanding of different argument types in python.

Variable arg2 has a * symbol. These variables take the variable number of arguments.

function1(9,12,45,0). The function called with values 9,12,45,0.

arg1 is assigned with a value nine.

12,45,0 is assigned to arg2.

Example 2

Q2) Check the below code and identify the output displayed.

Python Practice on Parameters Inheritance2
Program 2

The above program is an inheritance problem.

These types of programs are solved in a bottom-up approach.

__flatrent instance variable is a private variable.

We can not access the variable outside the class.

To access the private variable. We write getter and setter methods.

To get the value of the total rent variable.

The getter method is written in the program.

The setter method is written.To set the value to total rent variable.

The above example use method overriding and super-class constructor call.

With all these concepts, you should be flexible in solving the questions.

Created an object for furnished flat class, and variables are initialized with 7000 and 800.

Called the calculate total rent method using the furnished flat object.

The maintenance cost is 600.

Calculate total rent method is calling the super-class method with the value 300.

This is how it continues its execution. Analyze the output displayed.

The output displayed is 7950.

Example 3

Q3) Check the code given below. Identify the output displayed.

Python Practice on Parameters Inheritance3
Program 3

The output displayed by the program.

Final rent of each person : 2500

Initial rent : 4000