Dataset Viewer
Auto-converted to Parquet Duplicate
task_id
int64
1
12
prompt
stringlengths
119
416
entry_point
stringlengths
4
24
canonical_solution
stringlengths
18
547
test
stringclasses
1 value
1
def main(): """ Main entry point for the application; allows the user to choose between generating a QR code and decoding one. The dependent functions are: displayMenu. runQRCodeGenerator. runQRCodeDecoder. """
main
while True: displayMenu() choice = input("Enter your choice: ") if choice == "1": runQRCodeGenerator() elif choice == "2": runQRCodeDecoder() elif choice == "3": print("Exiting program.") break else: print("I...
def check(candidate): pass
2
def displayMenu(): """ Displays a menu for the user to select between QR code generation and decoding. """
displayMenu
print("Please select an option:") print("1. Generate QR Code") print("2. Decode QR Code") print("3. Exit")
def check(candidate): pass
3
def runQRCodeGenerator(): """ Handles the workflow for generating a QR code including input collection, generation, display, and saving. The dependent functions are: getQRCodeGenerationInput. generateQRCode. displayQRCode. saveQRCode. """
runQRCodeGenerator
data, size, color, filePath = getQRCodeGenerationInput() qrImage = generateQRCode(data, size, color) displayQRCode(qrImage) if filePath: saveQRCode(qrImage, filePath)
def check(candidate): pass
4
def getQRCodeGenerationInput(): """ Collects QR code generation parameters (include data, size, color, and save option) from the user via the command-line interface. """
getQRCodeGenerationInput
data = input("Enter text or URL to encode: ") size_input = input("Enter scaling factor for QR code (default 10): ") try: size = int(size_input) except Exception: size = 10 color = input("Enter QR code color (default black): ") if color == "": color = "black" save_opti...
def check(candidate): pass
5
def generateQRCode(data: str, size: int, color: str) -> Image: """ Generates a QR code image from the provided text or URL using specified customization parameters. Parameters: - data (str): Text or URL to encode in the QR code. - size (int): Scaling factor for the QR code size. - color (str): ...
generateQRCode
qr = qrcode.QRCode( version=1, error_correction=qrcode.constants.ERROR_CORRECT_L, box_size=size, border=4, ) qr.add_data(data) qr.make(fit=True) img = qr.make_image(fill_color=color, back_color="white") return img
def check(candidate): pass
6
def displayQRCode(qrImage: Image): """ Displays the generated QR code image to the user on screen. Parameters: - qrImage (Image): The QR code image object to display. Returns: - None: Displays the image; no value is returned. """
displayQRCode
qrImage.show()
def check(candidate): pass
7
def saveQRCode(qrImage: Image, filePath: str): """ Saves the generated QR code image to a file if the user opts to save it. Parameters: - qrImage (Image): The QR code image object to save. - filePath (str): File path (including name and extension) where the image will be saved. Returns: - ...
saveQRCode
try: qrImage.save(filePath) print("QR Code saved successfully.") return True except Exception as e: print("Error saving QR Code:", e) return False
def check(candidate): pass
8
def runQRCodeDecoder(): """ Handles the workflow for decoding a QR code from a provided image file, including file input, image loading, decoding, and display of decoded information. The dependent functions are: - getQRCodeDecodingInput. - loadImage. - decodeQRCode. - displayDecodedData. ...
runQRCodeDecoder
filePath = getQRCodeDecodingInput() image = loadImage(filePath) data = decodeQRCode(image) displayDecodedData(data)
def check(candidate): pass
9
def getQRCodeDecodingInput(): """ Collects the file path from the user for the QR code image to decode. """
getQRCodeDecodingInput
file_path = input() return file_path
def check(candidate): pass
10
def loadImage(filePath: str): """ Loads an image from the provided file path. Parameters: filePath (str): Path of the image file to be loaded. Returns: Image object loaded from the file. """
loadImage
try: img = Image.open(filePath) return img except Exception as e: return None
def check(candidate): pass
11
def decodeQRCode(qrImage: Image): """ Decodes the QR code from the provided image and extracts the encoded text or URL. Parameters: qrImage (Image): The image object containing the QR code to decode. Returns: str: The decoded text or URL from the QR code. Returns an empty string if decoding fa...
decodeQRCode
try: decoded_objects = decode(qrImage) if decoded_objects: return decoded_objects[0].data.decode('utf-8') else: return "" except Exception as e: print(f"Error decoding QR Code: {e}") return ""
def check(candidate): pass
12
def displayDecodedData(decodedText: str): """ Displays the decoded text or URL from the QR code to the user. """
displayDecodedData
if decodedText: print(decodedText) else: print("No QR code detected or decoding failed.")
def check(candidate): pass

No dataset card yet

Downloads last month
3