- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# Python Program to find out the price of a product after a number of days

Suppose, a person wants to buy a product of price x. But each passing day, the price of the product increases x times the price of the previous day. We have to find out the price of the product after y days since the person has made up his mind to purchase the product. If the price of the product is too much, then the answer is given as price modulo 10^9 + 7. The input is given in a list of pairs; the first value of the pair is the initial price x and the second value is y, the count of the days that have passed.

So, if the input is like nums = [(5, 2), (6, 8), (2, 12), (2722764242812953792238894584, 3486705296791319646759756475), (1505449742164712795427942455727527, 61649494321438487460747056421546274264)], then the output will be 25, 1679616, 4096, 754504594, 32955023

Here the output is 5^2 = 25, 6^8 = 1679616, 2^12 =4096, 2722764242812953792238894584^3486705296791319646759756475 = 754504594 (The value is given as value modulo 10^9 + 7), and so on.

To solve this, we will follow these steps −

- for i in range 0 to size of nums, do
- x,y := nums[i, 0], nums[i, 1]
- return the value x to the power y modulo 10^9 + 7

## Example

Let us see the following implementation to get better understanding −

def solve(nums): for i in range(len(nums)) : x,y = nums[i][0], nums[i][1] print(pow(x,y,1000000007)) solve([(5, 2),(6, 8),(2, 12) ,(2722764242812953792238894584, 3486705296791319646759756475) ,(1505449742164712795427942455727527, 61649494321438487460747056421546274264)])

## Input

[(5, 2),(6, 8),(2, 12) ,(2722764242812953792238894584, 3486705296791319646759756475) ,(1505449742164712795427942455727527, 61649494321438487460747056421546274264)]

## Output

25 1679616 4096 754504594 32955023

- Related Questions & Answers
- How to find the date after a number of days in R?
- C++ Program to find out the total price
- How to find out number of days in a month in MySQL?
- Program to find out the position of a ball after n reversals in Python
- Program to find out the sum of the maximum subarray after a operation in Python
- Program to Find Out the Number of Squares in a Grid in Python
- Program to find state of prison cells after k days in python
- Program to find out the dot product of two sparse vectors in Python
- Python Program to find out the number of sets greater than a given value
- Program to find out the number of accepted invitations in Python
- Java Program to find Product of unique prime factors of a number
- Python program to find number of days between two given dates
- Program to find out the number of pairs of equal substrings in Python
- C/C++ Program to find the Product of unique prime factors of a number?
- Program to find out the k-th largest product of elements of two arrays in Python