Question

CAN SOMEONE PLEASE HELP AND ANSWER THIS Introduction to computing and IT question

Question 4 (14 marks) This question assesses Block 2 Part 4 a. This part of the question involves creating two drawings. Youi. Include the algorithm for solving the problem in your solution document. Part ii of this question involves writing one Pyt----------------------------------------------------------------------------------------------------------------------------------------------------------------

this is the file required for the question

# TM1 12-19D-TMA02Q4_OUCU . py def amount of plastic(width brick, height brick, length brick, number of bricks) Given theassert amount of plastic (1. 2 3. 100) 4200 print (tests passed) test amount of plastic ()

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', python c o languages [0]'javascript' Draw the objects and labels that the Python interpreter creates in response to the first assignment. Then draw the objects and labels that results from carrying out the second assignment immediately after the first assignment For examples of such drawings, see Section 4.5 of Block 2 Part 4 (4 marks) b. Imagine you are working for a toy company that produces miniature solid plastic bricks. The company receives orders that specify the number of solid plastic bricks that is required o the width, height and length (in cm) of the bricks in this order. All bricks have the o same dimensions. 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. i. Include your initial decomposition of the problem in your solution document. ii. Include the algorithm for solving the problem in your solution document
i. Include the algorithm for solving the problem in your solution document. Part ii of this question involves writing one Python function definition. The download folder for this TMA contains the file TM112_19D_TMA02Q4_OUCU.py (go to TMA02- Python files ). Download the file and change OUCU to your OUCU number. Then open the file and inspect its contents. Write your Python function definition for anount of_plastic) in this file where indicated. Note that the file already contains code for automatically testing the function amount_of_plastic(). You learned about automatic testing of functions in Block 2 of Part 2. ili. 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 (10 marks) Total 14 marks) Question 3 (14 marks) Question 5 (14 marks)
# TM1 12-19D-TMA02Q4_OUCU . py 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 num # 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(l, l, 1, 0) 0 # Test for brick with dimensions 1, 1, 1 and # order of 20 bricks assert amount_of_plastic(l, 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 ()
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Question 4 a:

javascript java languages[0] =javascript python python languages languages

Question 4 b:

b(i)

Given width, length and height of a brick, we will first calculate the volume of a single brick. We are also provided with the number of bricks required, so we multiply number of bricks with volume of single brick to get the total volume of all the bricks.

Since 1 cm3 weighs 7 grams, we multiply total volume of all bricks with 7, to get the amount of total material required.

b(ii)

amount_of_plastic(width_brick,height_brick,length_brick,number_of_bricks):

volume_brick = width_brick * height_brick * length_brick

total_volume = volume_brick * number_of_bricks

plastic = total_volume * 7 return plastic

b(iii)

CODE:

def amount_of_plastic(width_brick,height_brick,length_brick,number_of_bricks):
    volume_brick = width_brick * height_brick * length_brick
    total_volume = volume_brick * number_of_bricks
    plastic = total_volume * 7
    return plastic

OUTPUT:

def amount of plastic(width brick,height brick,length brick,numberof bricks): volume_brick-width_brick * height_brick length

Add a comment
Know the answer?
Add Answer to:
CAN SOMEONE PLEASE HELP AND ANSWER THIS Introduction to computing and IT question --------------------------------------...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • volume_per_container python help

    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

  • List Python

    A car park management system uses a list to represent which spaces in a car park are currently occupied and which are currently unoccupied. An empty space is represented by a 0 and a full space by a 1. Then the state of the car park would be represented by the following list: [1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 0] The designers of the car park management system require a program that will accept a list such as the one above (although of course the length will not always be 11) and calculate what percentage of the spaces are currently occupied, rounded to the nearest percent. In the example above 7 spaces are occupied and there are 11 altogether, so the percentage occupied is: (7 / 11) x 100 = 63.63… = 64% to the nearest whole number. i.What are the admissible inputs of the problem? ii.What is the output of this problem? iii.Write three tests for this problem. The inputs should be different from the example given in the scenario description above. At least one of your tests must be a borderline case. Present the tests in a table, with a column for each input and output, and an extra column with a brief explanation of why you selected each test iv.Decompose the problem into sub-problems. Use the > notation and state in brackets the type of the problem and of each sub-problem v. Choose the patterns for the subproblem types you identified, instantiate the patterns into an algorithm, and translate the algorithm into code.This part of the question involves writing Python code. Write your code in this file and then submit the completed code file as part of the answer to this part of the question. Note: Although Python has a built-in function to find the sum of a list, please do not use it to compute how many 1s there are in the list. We want you to write your own code , because the purpose of this question is to practice following the problem solving approach described there, which will equip you to solve problems in other cases for which there is no built-in Python function. A Python program which is not preceded by a corresponding decomposition will gain at most half marks. Again, the reason for this is that we want you to follow a systematic problem-solving approach and not dive straight into code. Please therefore make sure that you have supplied an answer to iv. If you find it difficult to get the decomposition quite right at first there is no reason why you cannot review it when you have written the code. The main thing is to have a clear idea of what the solution needs to do (the decomposition) that ties in correctly with how it does it (the program). Make sure you use appropriate variable names and comments and that you have tested your code with the inputs of your test table. (Keep each of your test inputs in your code, but precede all of the test inputs, except for one, with the # symbol. Recall that # signals a comment, which is ignored by the Python interpreter.)

  • Please answer this question using python programming only and provide a screen short for this code....

    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...

  • Can you send the code and the screenshot of it running? 1) Create a PYHW2 document...

    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...

  • Answer in python 3 and can you please include a screenshot of the code and the...

    Answer in python 3 and can you please include a screenshot of the code and the output Problem 4 (Quicksort) For this problem you must implement the recursive quicksort algorithm covered in lecture to sort points based on their distance from the point (0, 0). Crete a Python file called quicksort.py and implement a function called quicksort(list) that does the following: COMP 1005/1405A – S19 – A5 Due Saturday, June 15th at 11:59 PM 3 1. Takes a 2D list...

  • PYTHON I need help with this Python problem, please follow all the rules! Please help! THANK...

    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 help! I'm really confused. Please answer question 1 with annual worth analysis and questio...

    MATLAB Please fix the error. Thank you!! Given the following piecewise function, f(x) Create a function M-file, PieceZig, that accepts one number as input, evaluates the piecewise function at that number & returns this as output. Do not allow the user to enter an armay of x values Examples Piecezig (1e) Piecezig (2) ans 2 Your Function 1 function fx PieceZ1g(x) 5 elseif ((-5 <= x)&&(x<= 5)) fx = x; 7 elseifx> 5 end end Test 1 Pretest) Test 2...

  • PYTHON please help! im stuck on this homework question, THANK YOU! please follow the rules! Give...

    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...

  • Your task is to: 1. Introduce function documentation (the triple-quoted string that precedes the definition of...

    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....

  • In matlab, I keep getting the same issue for this problem can someone help? "myrowproduct.m" >> Filename...

    In matlab, I keep getting the same issue for this problem can someone help? "myrowproduct.m" >> Filename myrowproduct (A,x) Undefined function or variable 'Filename' Did you mean: mfilename : myrowproduct (A, x) Undefined function or variable 'myrowproduct' function y = myrowproduct(A,x); function y my rowp roduct (A, x); Error: Function definition not supported in this context. Create functions in code file. (, 2,,)T 4. The product y Ax of an m x n matrix A times a vector x= can...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT