Questions: 5 831

Answers by our Experts: 5 728

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search & Filtering

Hollow Inverted Half Pyramid - 2

Given the number of rows N, write a program to print the hallow inverted half pyramid pattern similar to the pattern shown below.

1 2 3 4 5

1 4

1 3

1 2

1

Input


The input will be a single line containing a positive integer (N).

Output


The output should be N rows containing the numbers in the hollow inverted half pyramid pattern.

Note: There is a space after each number.


The media company "GlobalAd" has received a

batch of advertisements from different product

brands. The batch of advertisements is a

numeric value where each digit represents the

number of advertisements the media company

has received from different product brands.

Since the company banners permit only even

numbers of advertisements to be displayed, the

media company needs to know the total

number of advertisements it will be able to

display from the given batch.

Write an algorithm to calculate the total

number of advertisements that will be

displayed from the batch.

Input

The input consists of an integer batch,

representing the batch of advertisements

Output

Print an integer representing the total number

of advertisements that will be displayed by the

media company

Constraints

0 < batchs 109


Part 2

Invent your own function that does some useful computation of your choosing. Do not copy the function from somewhere else. Use incremental development, and record each stage of the development process as you go. Finally, print output that demonstrates that the function works as you intended.

Include all of the following in your Learning Journal:

  • An explanation of each stage of development, including code and any test input and output.
  • The output of three calls to your function with different arguments.

Part 1

Section 6.2 of your textbook describes incremental development. Do the exercise at the end of that section:

As an exercise, use incremental development to write a function called hypotenuse that returns the length of the hypotenuse of a right triangle given the lengths of the other two legs as arguments. Record each stage of the development process as you go. (Downey, 2015)

After the final stage of development, print the output of hypotenuse(3, 4) and two other calls to hypotenuse with different arguments.

Include all of the following in your Learning Journal:

  • An explanation of each stage of development, including code and any test input and output.
  • The output of hypotenuse(3,4).
  • The output of two additional calls to hypotenuse with different arguments.

def factorial(n):

space = ' ' * (4 * n)

print(space, 'factorial', n)

if n == 0:

print(space, 'returning 1')

return 1

else:

recurse = factorial(n-1)

result = n * recurse

print(space, 'returning', result)

return result

space is a string of space characters that controls the indentation of the output. Here is the

result of factorial(4) :


factorial 4

factorial 3

factorial 2

factorial 1

factorial 0

returning 1

returning 1

returning 2

returning 6

returning 24

If you are confused about the flow of execution, this kind of output can be helpful. It takes

"Debugging" lists three possibilities to consider if a function is not working.

  • Describe each possibility in your own words.
  • Define "precondition" and "postcondition" as part of your description.
  • Create your own example of each possibility in Python code. List the code for each example, along with sample output from trying to run it.
Write a program to check the overlapping of one strings suffix with the prefix of another string

For this question

Add two polynomials

Given two polynomials A and B, write a program that adds the given two polynomials A and B.

if the in puts are

4

0 5

1 0

2 10

3 6

4

0 -5

1 0

2 -10

3 -6

then the result is 0 but it is not showing the result from the code of Question #175894



Respond to the following question in at least three well composed paragraphs: What are the necessary conditions for a monopoly position in the market to be established?


Section 6.9 of your textbook ("Debugging") lists three possibilities to consider if a function is not working.

  • Describe each possibility in your own words.
  • Define "precondition" and "postcondition" as part of your description.
  • Create your own example of each possibility in Python code. List the code for each example, along with sample output from trying to run it.
  1. Does the submission include the is_divisible function from Section 6.4 of the textbook?
  2. Does the submission implement an is_power function that takes two arguments?
  3. Does the is_power function call is_divisible?
  4. Does the is_power function call itself recursively?
  5. Does the is_power function include code for the base case of the two arguments being equal?
  6. Does the is_power function include code for the base case of the two arguments being equal?
  7. Does the is_power function include code for the base case of the second argument being "1"?
  8. Does the submission include correct output for the five test cases?
LATEST TUTORIALS
APPROVED BY CLIENTS