1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
marusya05 [52]
3 years ago
10

Complete the function doubling_time that takes two parameters bal and apr and uses a while loop compute the number of years it t

akes for the initial balance in a bank account to double in value rounded up to the nearest year. The two parameters are: bal: initial balance in the bank account apr: annual percent interest income, this is the percentage (of the balance) that should be added to the balance every year as interest income. For example, if bal is 200 and apr is 10 then the balance should be 220 after the first year. Provided definition: # returns the doubling time of the balance in whole years def doubling_time (bal, apr):
Computers and Technology
1 answer:
worty [1.4K]3 years ago
4 0

Answer:

  1. def doubling_time(bal, apr):
  2.    current_amount = bal  
  3.    year = 0
  4.    while(current_amount < bal * 2):
  5.        current_amount = current_amount + (current_amount * apr/ 100)
  6.        year += 1
  7.    
  8.    return year
  9. print(doubling_time(200, 10))

Explanation:

The solution is written in Python 3.

Firstly create a function that takes two input bal and apr (Line 1). Next set the bal as current amount (Line 2) and create year variable as a counter of year (Line 3).

Create a while loop and set the loop condition to enable the while loop persist so long as the current amount still less than the double of initial balance (Line 4). In the while loop, apply formula to compute the current amount after adding the annual interest and then increment year counter by one (Line 5 -6). The year counter will keep increment until the current amount is double the initial balance and terminate the while loop. Return the year counter as function output (Line 8).

We test the function by passing 200 and 10 as initial balance and annual interest rate, respectively. We shall get return value 8.

You might be interested in
What is a "telescreen"? How is it different from the televisions we know? Is it possible to make a television that could see and
mars1129 [50]

Answer:

  1. Telescreens are devices that operate as televisions, security cameras, and microphones.
  2. A television is an electronic communication medium that allows the transmission of real-time visual images, and often sound while a telescreen is a television and security camera-like device used to keep things or people under constant surveillance, thus eliminating the chance of secret conspiracies.
  3. It could be employed in secretly investigating criminals and terrorists.
  4. It could also play a major role in politics by investigating suspicious government officials and those that plan Ill towards a nation.
  5. It would definitely be a great idea to install one of such.

Explanation:

8 0
3 years ago
Jack has determined that a virus has infiltrated his computer and corrupted several of his data files. Which two utilities would
Romashka [77]
Antivirus programs to detect and eliminate viruses such as Malwarebytes, Stinger, etc.

A hard drive to backup all of his remaining files.

Corrupted files are not always possible to recover, but it's worth a try using a software such as Recuva.
7 0
3 years ago
Read 2 more answers
So why is there often some Answer Expert Verified that are just 1 star rated or have the wrong answer? Don't quite a few people
miskamm [114]

Answer:

yeah, ive seen them.  I dont trust expert verified answers any more than regular ones.  

Explanation:

5 0
3 years ago
Class 00 rubber gloves are used when working with voltages less than​ _____.
Radda [10]
Answer: 500 volts AC, 750 volts DC
Class 00 rubber gloves are given the color "beige" based on the color code of rubber gloves.
The proof test voltage for this class of rubber gloves is 2500 volts of AC voltage and 10000 volts of DC voltage
4 0
3 years ago
Define a function below called average_num_in_file. The function takes one argument: the name of a file full of numbers. Complet
Nookie1986 [14]

Answer:

  1. def average_num_in_file(fileName):
  2.    with open(fileName) as file:
  3.        rows = file.readlines()
  4.        sum = 0
  5.        count = 0
  6.        for x in rows:
  7.            sum += float(x)  
  8.            count += 1
  9.        average = sum / count  
  10.    return average  
  11. print(average_num_in_file("cans.txt"))

Explanation:

The solution code is written in Python 3.

Firstly create a function that take one parameter, fileName (Line 1).

Open the file stream and use readlines method to read the data from the file (Line 2-3). Create variable sum and count to tract the total of the number from text files and number of data from the file (Line 5-6). Use a for loop to loop over each row of the read data and add the current value of each row to sum and increment the count by one (Line 7-9).

After the loop, calculate the average (Line 11) and return the result (Line 12).

At last, we can test the function by passing the cans.txt as argument (Line 14).

7 0
4 years ago
Other questions:
  • Can someone please answer this for me I will answer one of yours.
    13·1 answer
  • Where would you look to see how much space is available on your c drive?
    8·1 answer
  • How long is a subnet mask? (Please select one of the four options)
    5·1 answer
  • Which of the following statements opens the file info.txt for both input and output? a) dataFile.open("info.txt", ios::in &amp;&
    11·2 answers
  • The __________ is the system of official channels that carry organizationally approved messages and information.
    15·1 answer
  • The relational model describes data using a standard tabular format; all data elements are placed in three-dimensional tables ca
    5·1 answer
  • The activity, set of institutions, and processes for creating, capturing, communicating, delivering, and exchanging offerings th
    6·1 answer
  • A list that is not sorted by numbers is called a?
    10·1 answer
  • A presentation software that is used to organize and present pertinent information using graphics, word processing, outlining, d
    12·1 answer
  • Which group scope can be used to assign permissions to resources only in the domain in which the group is created
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!