BestPromptFinder
HomeCoding › Below is an instruction that describes a task. Write a respo...

Below is an instruction that describes a task. Write a respo...

Coding · General · Coding
55Quality
92%Useful
88Reliability

The prompt

Below is an instruction that describes a task. Write a response that appropriately completes the request. ### Instruction: Write a Python program to generate an HTML table displaying information about the top 10 bestselling books in a specific genre. ### Input: Table name: Books Table columns: id (int), title (string), author (string), genre (string), sales (int) ### Output: import sqlite3 # connect to the database conn = sqlite3.connect('books.db') c = conn.cursor() # retrieve the data c.execute('''SELECT title, author, genre, sales FROM Books WHERE genre='Fantasy' ORDER BY sales DESC LIMIT 10''') # save the results results = c.fetchall() # generate the HTML code html = ' ' html += ' Title Author Genre Sales ' for result in results: title = result[0] author = result[1] genre = result[2] sales = result[3] html += f' {title} {author} {genre} {sales} ' html += ' ' # display the results print(html)
Find similar in the app →

Why this prompt

Source

Hugging Face

Related Coding prompts

PRD to MVP Technical Plan
Quality 93 · Claude Code
Full-Stack CRUD App Builder
Quality 93 · Claude Code
Legacy Refactor Planner
Quality 93 · Claude Code
Test Suite Generator
Quality 93 · Claude Code
Third-Party API Integration
Quality 93 · Claude Code
Database Schema and Migration
Quality 93 · Claude Code