Here is the completed code for this problem. Comments are included, go through it, learn how things work and let me know if you have any doubts or if you need anything to change. If you are satisfied with the solution, please rate the answer. Thanks
#code
#required method
def pyramid_blocks(n,m,h):
#declaring number of blocks
blocks=0
#I dont have much knowledge in descrete math
or combinatorics, so I'm doing
#this the old fashioned way. the formula for
finding number of blocks
#is nm + (n+1)(m+1) + (n+2)(m+2) + ... +
(n+h-1)(m+h-1)
#looping from i=0 to i=h-1
for i in
range(h):
#finding (n+i * m+i)
and adding to blocks
blocks+=(n+i)*(m+i)
#returning blocks
return blocks
#testing
print(pyramid_blocks(2,3,1))
print(pyramid_blocks(2,3,10))
print(pyramid_blocks(10,11,12))
print(pyramid_blocks(100,100,100))
#output
6
570
3212
2318350
using python Blocks in pyramid def pyramid_blocks (n, m, h) A pyramid structure (although more in...
Please help with Python code.
testing for:
def pyramid_blocks_generator(seed):
n = 300
ns = it.islice(scale_random(seed, 3, 10), n)
ms = it.islice(scale_random(seed + 1, 3, 10), n)
hs = it.islice(scale_random(seed + 2, 2, 15), n)
yield from zip(ns, ms, hs)
def pyramid_blocks (n, m, h): A solid pyramid structure (although here in the ancient Mesoamerican than the more famous ancient Egyptian style) is built from layers, each layer consisting of a rectangle of identical cubic blocks. The top layer of the...
Help with solution using Python
test using
def riffle_generator(seed):
random.seed(seed)
for i in range(1000):
n = random.randint(0, 100)
items = [random.randint(0, 10**6) for j in range(2 * n)]
yield (items, True)
yield (items, False)
Riffle def riffle(items, out True): Given a list of items that is guaranteed to contain an even number of elements (note that the integer zero is an even number), create and return a list produced by performing a perfect riffle to the items by interleaving the...
Python Program Eratosthenes of Cyrene lived approximately 275-195 BC. He was the first to accurately estimate the diameter of the earth. For several decades he served as the director and chief librarian of the famous library in Alexandria. He was highly regarded in the ancient world, but unfortunately only fragments of his writing have survived. The algorithm described for this assignment is known as the Sieve of Eratosthenes. The algorithm is designed to find all prime numbers within a given...
please use python and provide run result, thank you!
click on pic to make it bigger
For this assignment you will have to investigate the use of the Python random library's random generator function, random.randrange(stop), randrange produces a random integer in the range of 0 to stop-1. You will need to import random at the top of your program. You can find this in the text or using the online resources given in the lectures A Slot Machine Simulation Understand...
You need not run Python programs on a computer in solving the following problems. Place your answers into separate "text" files using the names indicated on each problem. Please create your text files using the same text editor that you use for your .py files. Answer submitted in another file format such as .doc, .pages, .rtf, or.pdf will lose least one point per problem! [1] 3 points Use file math.txt What is the precise output from the following code? bar...
Company Case In-N-Out Burger: Customer Value the Old-Fashioned Way In 1948, Harry and Esther Snyder opened the first In-N-Out Burger in Baldwin Park, California. It was a simple double drive-thru setup with the kitchen between two service lanes, a walk-up window, and outdoor seating. The menu consisted of burgers, shakes, soft drinks, and fries. This format was common for the time period. In fact, another burger joint that fit this same description opened up the very same year just 45...
Please answer as many as possible!! QUESTION 10 As the hydrogen ion [H +] concentration in a solution decreases, the hydroxide ion [OH -] concentration increases and the pH increases. decreases and the pH increases. increases and the pH decreases. decreases and the pH stays the same. decreases and the pH decreases. 1 points QUESTION 11 Environmental science is a theoretical approach in interpreting the environment. way to see the world in scientific terms. narrowly defined set of physical,...
This C++ Program consists of: operator overloading, as well as experience with managing dynamic memory allocation inside a class. Task One common limitation of programming languages is that the built-in types are limited to smaller finite ranges of storage. For instance, the built-in int type in C++ is 4 bytes in most systems today, allowing for about 4 billion different numbers. The regular int splits this range between positive and negative numbers, but even an unsigned int (assuming 4 bytes)...
What an Executive Summary Is
An executive summary is a specific type of document that does
two things: it summarizes a research article, and it offers
recommendations as to how information from the article can be
used.
Some long reports can contain an executive summary section, as
indicated in the Pearson handbook.
Write a 2 pahe Executive Summary
In business contexts, an executive summary is always written
for a specific purpose: to explain the information in the article
to a...
How can we assess whether a project is a success or a
failure?
This case presents two phases of a large business transformation project involving the implementation of an ERP system with the aim of creating an integrated company. The case illustrates some of the challenges associated with integration. It also presents the obstacles facing companies that undertake projects involving large information technology projects. Bombardier and Its Environment Joseph-Armand Bombardier was 15 years old when he built his first snowmobile...