- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Accumulator battery in Python
Suppose we have a mobile phone which is in "eco mode". This mode activates once your battery level reaches 20 percent. In this eco mode the battery drains two times slower than in normal mode. Now when we leave our home, we have 100% of battery. Then t minutes after we have p percent of battery left. We have to find how many minutes we have until our phone will turn off.
So, if the input is like t = 75 and p = 25, then the output will be 45
To solve this, we will follow these steps −
if p < 20, then
otherwise return (p+20) *t/(100-p)
Let us see the following implementation to get better understanding −
class Solution: def solve(self, t, p): if p < 20: return 2*p*t/(120-2*p) return (p+20)*t/(100-p) ob = Solution() print(ob.solve(75, 25))
- Instruction to complement Accumulator in 8085 Microprocessor
- Instructions to rotate Accumulator in 8085 Microprocessor
- Accumulator or Register A in 8085 Microprocessor
- Reset Accumulator (8085 & 8086 microprocessor)
- Can a Mobile Phone Battery Track You?
- How to get battery level and state in Android?
- 8085 program to find the set bit of accumulator
- The New Smartphone Battery that Recharges in Just 30 Seconds
- C++ code to find out number of battery combos
- Save power of a laptop when runs on battery backup
- How can I get battery level and state (plugged in, discharging, charging, etc) in Android?
- How can I get battery level and state (plugged in, discharging, charging, etc) in iOS?
- Apply the Group Accumulator Operator $first on the system variable $$ROOT to return reference to the root document?
- What to do if a cab is not getting booked - especially when you are at a strange or lonely place and your phone battery is dying?
- ChainMap in Python