Skip to content
TheChatArchiveThe Chat Archive
Amazon Novaamazon.nova-pro-v1:0· AmazonHugging Face LMArena Human Preference 140K

Impress me with your coding skills

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Qwenqwen3-235b-a22b-no-thinking’s answer.
  1. User

    Impress me with your coding skills

  2. Amazon Nova Assistant

    Certainly! Here's an example of a Python script that demonstrates a variety of coding skills, including data structures, algorithms, and best practices. This script will create a simple command-line address book application.

    import json
    
    class AddressBook:
        def __init__(self):
            self.contacts = {}
    
        def add_contact(self, name, phone, email):
            self.contacts[name] = {'phone': phone, 'email': email}
            print(f"Contact {name} added.")
    
        def delete_contact(self, name):
            if name in self.contacts:
                del self.contacts[name]
                print(f"Contact {name} deleted.")
            else:
                print(f"Contact {name} not found.")
    
        def display_contacts(self):
            if not self.contacts:
                print("No contacts available.")
            else:
                for name, details in self.contacts.items():
                    print(f"Name: {name}, Phone: {details['phone']}, Email: {details['email']}")
    
        def save_to_file(self, filename):
            with open(filename, 'w') as file:
                json.dump(self.contacts, file)
            print(f"Address book saved to {filename}.")
    
        def load_from_file(self, filename):
            try:
                with open(filename, 'r') as file:
                    self.contacts = json.load(file)
                print(f"Address book loaded from {filename}.")
            except FileNotFoundError:
                print(f"File {filename} not found.")
    
    def main():
        address_book = AddressBook()
    
        while True:
            print("\nAddress Book Menu:")
            print("1. Add Contact")
            print("2. Delete Contact")
            print("3. Display Contacts")
            print("4. Save to File")
            print("5. Load from File")
            print("6. Exit")
    
            choice = input("Enter your choice: ")
    
            if choice == '1':
                name = input("Enter name: ")
                phone = input("Enter phone: ")
                email = input("Enter email: ")
                address_book.add_contact(name, phone, email)
            elif choice == '2':
                name = input("Enter name to delete: ")
                address_book.delete_contact(name)
            elif choice == '3':
                address_book.display_contacts()
            elif choice == '4':
                filename = input("Enter filename to save: ")
                address_book.save_to_file(filename)
            elif choice == '5':
                filename = input("Enter filename to load: ")
                address_book.load_from_file(filename)
            elif choice == '6':
                print("Exiting...")
                break
            else:
                print("Invalid choice. Please try again.")
    
    if __name__ == "__main__":
        main()
    

    Key Features:

    1. Object-Oriented Design: The AddressBook class encapsulates the functionality related to managing contacts.
    2. Data Persistence: Contacts can be saved to and loaded from a JSON file.
    3. User Interface: A simple command-line interface allows users to interact with the address book.
    4. Error Handling: Basic error handling for file operations.
    5. Code Organization: Clear separation of concerns between the AddressBook class and the main function.

    This script showcases good coding practices, including:

    • Use of classes for encapsulation.
    • Input validation and error handling.
    • File I/O operations for data persistence.
    • A simple yet effective user interface.

    Feel free to test and extend this script!

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.