answer.
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
den301095 [7]
1 year ago
5

Budget Analysis (use while loop) Write a program that asks the user to enter the amount that he or she has budgeted for a month.

A loop should then prompt the user to enter each of his or her expenses for the month and keep a running total. When the loop finishes, the program should display the amount that the user is over or under budget.
Computers and Technology
1 answer:
Agata [3.3K]1 year ago
6 0

Answer:

print('This program will help you determine whether you\'ve budgeted enough ' +

     'for your expenses. You\'ll just need to enter your budget and the ' +

     'cost of each of your expenses for the month and we will calculate ' +

     'the balance.')

budget = float(input('How much have you budgeted this month? '))

expenses = 0

check = 0

while check >= 0:

   check = float(input('Enter an expense amount or -1 to quit: '))

   if check != -1:

       expenses += check

balance = budget - expenses

if balance < 0:

   print('\nYou haven\'t budgeted enough. You\'re going to be $', \

         format(-1 * balance, ',.2f'), ' short this month.', sep = '')

elif balance == 0:

   print('\nBe careful. You\'ve budgeted just enough to make it through ' +

         'the month.')

else:

   print('\nYou will have $', format(balance, ',.2f'), ' extra this month.', \

         sep = '')

You might be interested in
8.Change the following IP addresses from binary notation to dotted-decimal notation: a.01111111 11110000 01100111 01111101 b.101
Andrews [41]

Answer:

a. 01111111 11110000 01100111 01111101 dotted decimal notation:

(127.240.103.125)

b. 10101111 11000000 11111000 00011101 dotted decimal notation: (175.192.248.29)

c. 11011111 10110000 00011111 01011101 dotted decimal notation:

(223.176.31.93)

d. 11101111 11110111 11000111 00011101 dotted decimal notation:

(239.247.199.29)

a. 208.34.54.12 class is C

b. 238.34.2.1 class is D

c. 242.34.2.8 class is E

d. 129.14.6.8 class is B

a.11110111 11110011 10000111 11011101 class is E

b.10101111 11000000 11110000 00011101 class is B

c.11011111 10110000 00011111 01011101 class is C

d.11101111 11110111 11000111 00011101 class is D

Explanation:

8 a. 01111111 11110000 01100111 01111101

we have to convert this binary notation to dotted decimal notation.

01111111 = 0*2^7 + 1*2^6 + 1*2^5 + 1*2^4 + 1*2^3 + 1*2^2 + 1*2^1 + 1*2^0

           = 0 + 1*64 + 1*32 + 1*16 + 1*8 + 1*4 + 1*2 + 1

           = 64 + 32 + 16 + 8 + 4 + 2 + 1

           = 127

11110000 = 1*2^7 + 1*2^6 + 1*2^5 + 1*2^4 + 0*2^3 + 0*2^2 + 0*2^1 + 0*2^0

               = 1*128 + 1*64 + 1*32 + 16 + 0 + 0 + 0 + 0

               = 128 + 64 + 32 + 16

               = 240

01100111 = 0*2^7 + 1*2^6 + 1*2^5 + 0*2^4 +0*2^3 + 1*2^2 + 1*2^1 + 1*2^0

               = 0 + 1*64 + 1*32 + 0 + 0 + 4 + 2 + 1

               = 64 + 32 + 4 + 2 + 1

               = 103

01111101   = 0*2^7 + 1*2^6 + 1*2^5+ 1*2^4 +1*2^3 +1*2^2 + 0*2^1 + 1*2^0

               = 0 + 1*64 + 1*32 + 1*16 + 1*8 + 1* 4 + 0 + 1

               = 64 + 32 + 16 + 8 + 4 + 1

               = 125

So the IP address from binary notation 01111111 11110000 01100111 01111101 to dotted decimal notation is : 127.240.103.125

b) 10101111 11000000 11111000 00011101

10101111 = 1*2^7 + 0*2^6 + 1*2^5 + 0*2^4 + 1*2^3 + 1*2^2 + 1*2^1 + 1*2^0

             = 175

11000000 = 1*2^7 + 1*2^6 + 0*2^5 + 0*2^4 + 0*2^3 + 0*2^2 + 0*2^1 + 0*2^0

                 = 192

11111000 = 1*2^7 + 1*2^6 + 1*2^5 + 1*2^4 +1*2^3 + 0*2^2 + 0*2^1 + 0*2^0

              = 248

00011101 = 0*2^7 + 0*2^6 + 0*2^5 + 1*2^4 +1*2^3 + 1*2^2 + 0*2^1 + 1*2^0

               = 29

So the IP address from binary notation 10101111 11000000 11111000 00011101  to dotted decimal notation is : 175.192.248.29

c) 11011111 10110000 00011111 01011101

11011111 = 1*2^7 + 1*2^6 + 0*2^5 + 1*2^4 +1*2^3 + 1*2^2 + 1*2^1 + 1*2^0

           = 223

10110000 =  1*2^7 + 0*2^6 + 1*2^5 + 1*2^4 +0*2^3 + 0*2^2 + 0*2^1 + 0*2^0

                = 176

00011111 = 0*2^7 + 0*2^6 + 0*2^5 + 1*2^4 +1*2^3 + 1*2^2 + 1*2^1 + 1*2^0

              = 31

01011101 = 0*2^7 + 1*2^6 + 0*2^5 + 1*2^4 +1*2^3 + 1*2^2 + 0*2^1 + 1*2^0

              = 93

So the IP address from binary notation 11011111 10110000 00011111 01011101 to dotted decimal notation is :223.176.31.93

d) 11101111 11110111 11000111 00011101

11101111 = 1*2^7 + 1*2^6 + 1*2^5 + 0*2^4 +1*2^3 + 1*2^2 + 1*2^1 + 1*2^0

            = 239

11110111 = 1*2^7 + 1*2^6 + 1*2^5 + 1*2^4 +0*2^3 + 1*2^2 + 1*2^1 + 1*2^0

           = 247

11000111 =  1*2^7 + 1*2^6 + 0*2^5 + 0*2^4 +0*2^3 + 1*2^2 + 1*2^1 + 1*2^0

              = 199

00011101 = 0*2^7 + 0*2^6 + 0*2^5 + 1*2^4 +1*2^3 + 1*2^2 + 0*2^1 + 1*2^0

               = 29

So the IP address from binary notation 11101111 11110111 11000111 00011101 to dotted decimal notation is : 239.247.199.29

9. In order to the find the class check the first byte of the IP address which is first 8 bits and check the corresponding class as follows:                

Class A is from 0 to 127

Class B is from 128 to 191

Class C is from 192 to 223

Class D is from 224 to 239

Class E is from 240 to 255

a. 208.34.54.12

If we see the first byte of the IP address which is 208, it belongs to class C as class C ranges from 192 to 223.

b. 238.34.2.1

If we see the first byte of the IP address which is 238, it belongs to class D as Class D ranges from 224 to 239.

c. 242.34.2.8

If we see the first byte of the IP address which is 242, it belongs to class E as Class E ranges from 240 to 255.

d. 129.14.6.8

If we see the first byte of the IP address which is 129, it belongs to class B as Class B ranges from 128 to 191.

10. In order to find the class of the IP addresses in easy way, start checking bit my bit from the left of the IP address and follow this pattern:

0 = Class A

1 - 0 = Class B

1 - 1 - 0 = Class C

1 - 1 - 1 - 0 = Class D

1 - 1 - 1 - 1 = Class E

a. 11110111 11110011 10000111 11011101

If we see the first four bits of the IP address they are 1111 which matches the pattern of class E given above. So this IP address belongs to class E.

b. 10101111 11000000 11110000 00011101

If we see the first bit is 1, the second bit is 0 which shows that this is class B address as 1 0 = Class B given above.

c. 11011111 10110000 00011111 01011101

The first bit is 1, second bit is 1 and third bit is 0 which shows this address belongs to class C as 110 = Class C given above.

d. 11101111 11110111 11000111 00011101

The first bit is 1, the second bit is also 1 and third bit is also 1 which shows that this address belongs to class D.

3 0
1 year ago
A computer has 4 GB of RAM of which the operating system occupies 512 MB. The processes are all 256 MB (for simplicity) and have
Afina-wow [57]

Answer:

1-p^{14} = 0.99

p^{14}= 0.01

p =(0.01)^{1/14}= 0.720

So then the value of the maximum I/O wait that can be tolerated is 0.720 or 72 %

Explanation:

Previous concepts

Input/output operations per second (IOPS, pronounced eye-ops) "is an input/output performance measurement used to characterize computer storage devices like hard disk drives (HDD)"

Solution to the problem

For this case since we have 4GB, but 512 MB are destinated to the operating system, we can begin finding the available RAM like this:

Available = 4096 MB - 512 MB = 3584 MB

Now we can find the maximum simultaneous process than can use with this:

\frac{3584 MB}{256 MB/proc}= 14 processes

And then we can find the maximum wait I/O that can be tolerated with the following formula:

1- p^{14}= rate

The expeonent for p = 14 since we got 14 simultaneous processes, and the rate for this case would be 99% or 0.99, if we solve for p we got:

1-p^{14} = 0.99

p^{14}= 0.01

p =(0.01)^{1/14}= 0.720

So then the value of the maximum I/O wait that can be tolerated is 0.720 or 72 %

3 0
1 year ago
Write a function called sum_scores. It should take four arguments, where each argument is the team's score for that quarter. It
saw5 [17]

Answer:

Here is the Python program which has a function sum_scores:

def sum_scores(score1, score2, score3, score4):

   sum = score1 + score2 + score3 + score4

   print(sum)    

sum_scores(14,7,3,0)

Explanation:

  • Method sum_scores takes four arguments, score1, score2, score3, score4.
  • The sum variable adds these four scores and stores the value of their addition.
  • Lastly print statement is used to print the value stored in sum variable which is the value obtained by adding the four scores.
  • Last statement calls the sum_scores method and passes four values to it which are 14,7,3,0
  • The output of the above program is:
  • 24
  • If you want to use return statement instead of print statement you can replace print(sum) with return sum. But in order to display the sum of the scores you can replace sum_scores(14,7,3,0) with print(sum_scores(14,7,3,0))
  • The program along with the output is attached as a screenshot.

5 0
2 years ago
Given positive integer n, write a for loop that outputs the even numbers from n down to 0. If n is odd, start with the next lowe
seropon [69]

Answer:

The program in Python is as follows:

n = int(input("Enter an integer: "))

if n < 0:

   n = 0

print("Sequence:",end=" ")

for i in range(n,-1,-1):

   if i%2 == 0:

       print(i,end = " ")

Explanation:

This gets input for n

n = int(input("Enter an integer: "))

This sets n to 0 if n is negative

<em>if n < 0:</em>

<em>    n = 0</em>

This prints the string "Sequence"

print("Sequence:",end=" ")

This iterates from n to 0

for i in range(n,-1,-1):

This check if current iteration value is even

   if i%2 == 0:

If yes, the number is printed

       print(i,end = " ")

7 0
1 year ago
An app builder has created a report for sales people to view records from the custom object, some users have complained that the
Mila [183]

Answer:

There is a need for some people to see the total transparency of the records that are meant to be shared with a select group of people. There are certain things that can be done for this. The first one is that the sharing rules should be checked. To whom are the details shared with. The next one is the filters that are used.

These can be reported and changed accordingly. Lastly, the whole organization’s defaults can be checked. This is something that can be done when the previous methods that were done did not work that well. Once some changes are done, the people can check if they already work and if the records can be viewed.

Explanation:

8 0
1 year ago
Other questions:
  • A chemical found in the synaptic vesicles , which , when released . has an effect on the next cell is called a?
    10·1 answer
  • Which Android application is used exclusively for sharing video content?
    12·2 answers
  • Monica needs to work on a document where she has to highlight topics in bold and add emphasis to some words in a paragraph using
    9·1 answer
  • Modern operating systems decouple a process address space from the machine’s physical memory. List two advantages of this design
    15·1 answer
  • Apart from the challenges of heterogeneity, business and social change and trust and security, identify other problems and chall
    9·1 answer
  • In a real-world environment, changing granularity requirements might dictate changes in primary key selection, and those changes
    15·1 answer
  • How many times does the following loop execute?int upperCaseLetters = 0;String str = "abcdEfghI";boolean found = false;for (int
    5·1 answer
  • Access-lists pose a logical problem which often has more than one solution. Can you think of a different set of rules or placeme
    8·1 answer
  • Chris accidentally steps on another student’s foot in the hallway. He apologizes, but the other student does not want to hear it
    13·2 answers
  • Write a statement that assigns total_coins with the sum of nickel_count and dime_count. Sample output for 100 nickels and 200 di
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!