When it is required to take a number and compute a specific pattern, the value of n is taken from the user. Next, two variables are assigned this specific pattern and their sum is calculated.
Below is a demonstration of the same −
Example
my_input = int(input("Enter a value for n..."))
temp_val = str(my_input)
t_1=temp_val+temp_val
t_2=temp_val+temp_val+temp_val
my_result = my_input+int(t_1)+int(t_2)
print("The computed value is : ")
print(my_result)Output
Enter a value for n...4 The computed value is : 492
Explanation
An input from the user is taken.
It is converted into a string and assigned to a variable.
The value of ‘n*n’ and the value of ‘n*n*n’ is calculated.
Their sum is determined.
This sum is assigned to a variable.
This is displayed as the output.