Need some help to answer these questions please;
Question 4
b. Imagine you are working for a toy company that produces miniature solid plastic bricks. The company receives orders that specify:
Given a specific order, the problem is to compute the amount of plastic, in grams, that is needed to produce the bricks for that order.
Assume that 1 cm3 of plastic weighs 7 grams.
In answer to this question you will need to decompose the problem, write an algorithm, and implement the algorithm as a single python function that returns the amount of plastic that is needed given a specific order.
Part iii of this question involves writing one Python function definition. Below is the Python script. Inspect its contents and write your Python function definition for amount_of_plastic() in this script where indicated. Note that the script already contains code for automatically testing the function amount_of_plastic()
---------------------------------------------------------------------------------------------------------------
def amount_of_plastic(width_brick, height_brick, length_brick, number_of_bricks):
"""Given the dimensions of a brick (width, height, length in cm) and the number of bricks ordered, calculate how much plastic, in grams, is required (if a cubic centimetre weighs 7 grams)."""
# INSERT YOUR CODE BELOW THIS LINE FOR CALCULATING THE
# AMOUNT OF PLASTIC AND RETURNING THE RESULT (DO NOT CHANGE
# THE HEADER OF THE FUNCTION WHICH HAS BEEN PROVIDED FOR YOU
# ABOVE)
# DO NOT CHANGE THE CODE BELOW THIS LINE
# The code below automatically tests your function
# following the approach described in
# Block 2 Part 4 (Page 207 and further).
# Before making any changes to this file,
# when you run it, you will get an AssertionError.
# Once you have completed the file with correct
# code, the AssertionError should no longer appear and
# "tests passed" will appear in the shell.
def test_amount_of_plastic():
"""Test the amount_of_plastic() function."""
# Test for brick with dimensions 0, 0, 0 and
# order of 20 bricks
assert amount_of_plastic(0, 0, 0, 20) == 0
# Test for brick with dimensions 1, 1, 1 and
# order of 0 bricks
assert amount_of_plastic(1, 1, 1, 0) == 0
# Test for brick with dimensions 1, 1, 1 and
# order of 20 bricks
assert amount_of_plastic(1, 1, 1, 20) == 140
# Test for brick with dimensions 1, 2, 3 and
# order of 100 bricks
assert amount_of_plastic(1, 2, 3, 100) == 4200
print ("tests passed")
test_amount_of_plastic()
--------------------------------------------------------------------------------------------------------------
iii. Provide a Python function that implements the algorithm. Follow the instructions above for submitting code. You need to submit the .py file with your function (following the instructions provided above), and also paste a copy of all the code in your file into your solution document as text.
Decomposition:
Algorithm:
ALGORITHM AmountOfPlastic
INPUT : BrickWidth, BrickHeight, BrickLength, BrickQuantity
OUTPUT : PlasticWeight
SingleBrickVolume <-- BrickWidth * BrickHeight * BrickLength
TotalBrickVolume <-- SingleBrickVolume * BrickQuantity
PlasticVolume <-- BrickVolume
PlasticWeight <-- PlasticVolume * 7
## Python code begins ##
def amount_of_plastic(width_brick, height_brick, length_brick,
number_of_bricks):
single_brick_volume = width_brick * height_brick
* length_brick
total_brick_volume = single_brick_volume *
number_of_bricks
plastic_volume = total_brick_volume
plastic_weight = plastic_volume * 7
return plastic_weight
## Python code ends ##


Need some help to answer these questions please; Question 4 b. Imagine you are working for...
CAN SOMEONE PLEASE HELP AND ANSWER THIS Introduction to
computing and IT question
----------------------------------------------------------------------------------------------------------------------------------------------------------------
this is the file required for the question
Question 4 (14 marks) This question assesses Block 2 Part 4 a. This part of the question involves creating two drawings. You can make your drawings whichever way is easiest or fastest for you. For instance, you could simply make your drawings using pencil and paper then scan or photograph them. Consider the following two assignments: o languages-['java',...
Imagine that a company in the freight transport business has commissioned you to solve the following problem. Given bulk cargo with a certain weight per m3, compute the volume of that bulk cargo in m3 that a single 40-foot standard container can hold. A standard 40-foot container: has an internal volume of 67.5 m3 a maximum net load of 26199 kg . For instance, 1 m3 of gravel weighs 1800 kg. Because the maximum net load of a container is 26199 kg, a single container can only hold 14.555 m3 of gravel, otherwise it would exceed the maximum net load. For comparison, 1 m3 of wood chips weighs 380 kg. Because the maximum net load of a container is 26199 kg, based on the maximum weight, it is allowed to hold 68.94 m3 of wood chips. However, the internal volume of a single container is only 67.5 m3, so a single container can hold 67.5 m3 of wood chips. In answer to this question you will need to decompose the problem, write an algorithm, and implement the algorithm as a single python function that returns the total volume that can be held by single container. i.Include your initial decomposition of the problem in your solution document using the chevron notation (> and >>) ii.Include the algorithm for solving the problem in your solution document. Part iii of this question involves writing one Python function definition. —— Draft Code—— def volume_per_container(kg_cargo_per_cubic_metre): """Given the kg of cargo per cubic metre, calculate how many cubic metres of cargo can be stored in a single container.""" # INSERT YOUR CODE BELOW FOR CALCULATING THE # TOTAL WEIGHT AND RETURNING THE RESULT (DO NOT CHANGE # THE HEADER OF THE FUNCTION WHICH HAS BEEN PROVIDED FOR YOU # ABOVE) # DO NOT CHANGE THE CODE BELOW # The code below automatically tests your function # If you run this file before making any changes to # it, you will get an AssertionError. # Once you have completed the file with correct # code, the AssertionError should no longer appear and # message "tests passed" will appear in the shell. def test_volume_per_container(): """Test the volume_per_container function.""" # Test for gravel at 1800 kg per cubic metre assert volume_per_container(1800) == 14.555 # Test for wood chips at 380 kg per cubic metre assert volume_per_container(380) == 67.5 print ("tests passed") test_volume_per_container() ——— End Draft Code———— Write your Python function definition for volume_per_container() in the draft code where indicated. Note that the Draft Code already contains code for automatically testing the function volume_per_container(). You must not change this code. iv. Provide a Python function that implements the algorithm. Follow the instructions above for submitting code. Your answer must be a translation of your algorithm from part (ii) above
Your task is to: 1. Introduce function documentation (the triple-quoted string that precedes the definition of a Python function) 2. Make sundry changes to improve the readability of the code. This might include: 1. Be sure to change the function names to something appropriate. 2. If there are any "gotchas" or assumptions about the input, document those. 3. If the variables are poorly named, change the variable names. 4. If the logic is needlessly complicated or redundant, abbreviate it. 3....
PYTHON please help! im stuck on this homework
question, THANK YOU! please follow the rules!
Give a recursive python implementation of the following function: def check_Decreasing_Order(lissy): Given lissy, a python list of integers, the above function will return True if lissy is sorted in decreasing order, otherwise it will return false. For example, print(check_Decreasing Order([100,50,8, -2])) True print(check_Decreasing_Order([108,50,8,2,35])) False Implementation Requirements: 1. Your implementation must be recursive. 2. If you need more parameters, you may define new functions or helper...
Can you send the code and the screenshot of it running?
1) Create a PYHW2 document that will contain your algorithms in flowchart and pseudocode form along with your screen shots of the running program. 2) Create the algorithm in both flowchart and pseudocode forms for the following two functions: A. Write a Python function that receives a real number argument representing the sales amount for videos rented so far this month The function asks the user for the number...
PYTHON I need help with this Python problem,
please follow all the rules! Please help! THANK YOU!
Bonus Question Implement an efficient algorithm (Python code) for finding the 11th largest element in a list of size n. Assume that n will be greater than 11. det find 11th largest numberlissy Given, lissy, a list of n integers, the above function will return the 11th largest integer from lissy You can assume that length of lissy will be greater than 11....
Please answer this question using python programming only and provide a screen short for this code. Homework 3 - Multiples not less than a number Question 1 (out of 3) This homework is a SOLO assignment. While generally I encourage you to help one another to learn the material, you may only submit code that you have composed and that you understand. Use this template to write a Python 3 program that calculates the nearest multiple of a number that...
need help on all parts please and thank you
(e) What is the correct output of this code? (2 pts) >>> def func(x): >>> res = 0 >>> for i in range (len (x)): res i >>> return res >>> print (func(4)) ( 4 5 ) 6 ()7 ( What could be described as an immutable list? (2 pts) () a dimple ( ) a tuple ( ) a truffle () a dictionary (g) What is the result of the...
PYTHON this implementation is really hard, Im stuck
especially with the requirements they give. PLEASE HELP! THANK YOU!
RECURSIVE!
Give a recursive python implementation of the following function: def check_Decreasing_Order(lissy): Given lissy, a python list of integers, the above function will return True if lissy is sorted in decreasing order, otherwise it will return false. For example, print(check_Decreasing Order([100,50,8, -2])) True print(check_Decreasing_Order([108,50,8,2,35])) False Implementation Requirements: 1. Your implementation must be recursive. 2. If you need more parameters, you may define...
I need a python 3 help. Please help me with this question Part 2. Linked Lists You start working with the class LinkNode that represents a single node of a linked list. It has two instance attributes: value and next. class LinkNode: def __init__(self,value,nxt=None): assert isinstance(nxt, LinkNode) or nxt is None self.value = value self.next = nxt Before you start with the coding questions, answer the following questions about the constructor Valid Constructor or Not? LinkNode(1, 3) LinkNode(1, None) LinkNode(1,...