Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#Create a loop, preferably while, that visits every #tile on a grid with a pre-stored width and height, and #returns the tiles that are inside

#Create a loop, preferably while, that visits every #tile on a grid with a pre-stored width and height, and #returns the tiles that are inside of a specific column #entered by the user, in order, separated by spaces. #Columns start at column 0.

import subprocess

def template(w,h,c):

width = w height = h column = c result = "1" return result #END OF YOUR CODE

test1 = template(4,3,0) test2 = template(4,3,3) test3 = template(4,3,1)

failed = False

if (test1 == "1 5 9" or test1 == "1 5 9 "): print "for a 4x3 board with column 0, you got it RIGHT!" else: print "for a 4x3 board, we expected '1 5 9' , you got: " + str(test1) failed = True if (test2 == "4 8 12" or test2 == "4 8 12 "): print "for a 4x3 board with column 3, you got it RIGHT!" else: print "for a 4x3 board with column 3, we expected '4 8 12' , you got: " + str(test2) failed = True if (test3 == "2 6 10" or test3 == "2 6 10 "): print "for a 4x3 board with column 1, you got it RIGHT!" else: print "for a 4x3 board with column 1, we expected '2 6 10' , you got: " + str(test3) failed = True

if failed == False: print "Your code is CORRECT!" result = subprocess.check_output else: print "Please check your code, at least one test case did not pass." result = subprocess.check_output

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data Systems A 360-degree Approach

Authors: Jawwad ShamsiMuhammad Khojaye

1st Edition

0429531575, 9780429531576

More Books

Students also viewed these Databases questions

Question

Calculate the pH of 5.0 10-8 M HNO3.

Answered: 1 week ago