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
HACTEHA [7]
3 years ago
5

Write a Python program to balance a checkbook. The main function needs to get the initial balance, the amounts of deposits, and

the amounts of checks. Allow the user to process as many transactions as desired; use separate functions to handle deposits and checks.
Computers and Technology
1 answer:
Irina18 [472]3 years ago
5 0

Answer:

def deposit(deposit_amount, balance):

   balance += deposit_amount

   return balance;

def process_check(check_amount, balance):

   balance -= check_amount

   return balance;

balance = float(input("Enter the initial balance: "))

transaction = input("Choose transaction method - D to deposit, C to process check, Q to quit: ")

while transaction != 'Q':

   if transaction == 'D':

       deposit_amount = float(input("Enter amount to be deposited: "))

       balance = deposit(deposit_amount, balance)

       print("Current balance is: " + str(balance))

   elif transaction == 'C':

       check_amount = float(input("Enter amount to process check: "))

       if balance >= check_amount:

           balance = process_check(check_amount, balance)

           print("Current balance is: " + str(balance))

       else:

           print("Not enough money!")

   else:

       print("Invalid input!")

   transaction = input("Choose transaction method - D to deposit, C to process the check, Q to quit: ")

print("Your final balance is: " + str(balance))

Explanation:

- Create functions to handle deposits and checks

- Ask the user for the initial balance and transaction to be made

- Initialize a while loop iterates until the user enter Q

- Ask the deposit amount or check amount depending on the transaction chosen

- Calculate and print the current balance for each transaction

- Print the final balance

You might be interested in
How do you open an application on the macOS?
timama [110]

Click the Launchpad icon in the Dock, or pinch closed with your thumb and three fingers on your trackpad. Then click an app to open it. You can also type an app's name to find the app in Launchpad, then press the Return key to open it.

3 0
3 years ago
Read 2 more answers
Assign sub_lyric by slicing rhyme_lyric from start_index to end_index which are given as inputs. Sample output with inputs: 4 7
N76 [4]

sub_lyric = rhyme_lyric[start_index:end_index]

8 0
4 years ago
Case 2-2 Jack has a computer at home that he uses to access the Internet, store and edit personal photos, and create and edit do
bekas [8.4K]

Answer:

Check button under error checking

Explanation:

Under the Tools tab there are two options:

Error checking and Optimize and defragment drive option.

clicking the check button with administrative permission under error checking option will examine the hard drive for errors.

3 0
3 years ago
The instruction format of a computer is given by one indirect bit, opcode bits, register address bits, immediate operand bits an
oksian1 [2.3K]

Answer:

Following are the answer to this question:

Explanation:

A)

The memory size is 1 Giga Bytes which is equal to 2^{30}

\texttt{Number of address bits    \ \ \ \ \ \ \ \ \ \ \ \ \ \            Number of addresses}\\\\ \ \ \ \ 30  \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \  \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \                                 2^{30}= 1073741824

B) \texttt{I \ \ \ Opcode  \ \ \ Register address \ \ \  Immediate operand \ \ \    Memory address}\\\\\\\textt{1 \ bit  \  \ \ \ \ \ 128  \ \ \ \ \ \ \ \ \ \ \ \ \ \ \    2 \ bits   \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \   24 \ bits  \ \ \ \ \ \ \ \ \ \ \ \ \ \ \  \ \ \ \ \ \ \ \ \           30 \ bits}\\\\\\            = 2^7 \\\\ = 7 \ bits

calculating the register Bits:

= 64-(1+7+24+30)\\\\=64 -62\ \  bits\\\\= 2\ \ bits\\

C)

Immediate value size while merging the additional benefit with the address field:

= 2^{24} + 2^{30}\\\\= 2^{54}\\\\\texttt{Range before combining(-,+) 24 bits   \ \ \ \ \ \       Range after combining( -,+)54bits}\\\\                         \textt{-2^{12} from + (2^{12}-1)   \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \                                    -2^{27} from + (2^{27}- 1)}

= \frac{24}{2} = 12\\\\= \frac{54}{2} = 27

The range is accomplished by dividing the bits by 2 into the two sides of the o and the number is one short to 0.

8 0
3 years ago
The key do you use to copy and paste?
Snowcat [4.5K]

Answer:

Copy crl c PASTE is ctrl v

3 0
2 years ago
Read 2 more answers
Other questions:
  • Write a Python program that gets a number using keyboard input. (Remember to use input for Python 3 but raw_input for Python 2.)
    8·1 answer
  • What feature is required to send data from a web-connected device (like a point-of-sale system) to Google Analytics?
    14·1 answer
  • How to find no of Distinct triangles in a polygon?
    10·1 answer
  • - The concept of communication competence suggests there is no single "ideal" or "effective" way to communicate in every situati
    6·2 answers
  • Assume we perform a known-plaintext attack against DES with one pair of plaintext and ciphertext. How many keys do we have to te
    14·1 answer
  • This is more opinionated than question-based.
    7·1 answer
  • Inserting merge fields in the letter<br>steps required <br>plz ​
    11·2 answers
  • The term platform as a service has generally meant a package of security services offered by a service provider that offloads mu
    9·1 answer
  • You are creating a program that can add up the amount of money the user spent that day. Right down to the penny! What kind of va
    12·2 answers
  • Why is it a good idea to only use one word for everything you create in Scratch, even though you can technically use two words f
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!