Skip to content
The Chat Archive
Geminigemini-2.0-flash-001· GoogleHugging Face LMArena Human Preference 140K

Create me a python script that will output animation in terminal. Animation will be…

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

    Create me a python script that will output animation in terminal. Animation will be pikatchu runing.

  2. Gemini Assistant
    import time
    import os
    
    # Pikachu animation frames
    frames = [
        """
        (\\_/)
        (='.'=)
        (")-(")  __
          || //  | \\
        _ || \\  |  |
       /  ^--^   | /
      /     \\  /
      |  /\\ |
      `--' `--'
        """,
        """
        (\\_/)
        (='.'=)
        (")-(")  _
          || //  | \\
        _ || \\  |  |
       /  ^--^   | /
      /     \\  /
      |  /\\ |
      `--' `--'
        """,
        """
        (\\_/)
        (='.'=)
        (")-(")
          || //  | _
        _ || \\  |  |
       /  ^--^   | /
      /     \\  /
      |  /\\ |
      `--' `--'
        """,
        """
        (\\_/)
        (='.'=)
        (")-(")
          || //  |
        _ || \\  |_
       /  ^--^   | /
      /     \\  /
      |  /\\ |
      `--' `--'
        """,
    ]
    
    
    def animate_pikachu(speed=0.2):
        """
        Animates Pikachu running in the terminal.
    
        Args:
            speed: The speed of the animation (lower value = faster).  Default is 0.2 seconds between frames.
        """
    
        try:
            while True:  # Run animation indefinitely (or until interrupted)
                for frame in frames:
                    os.system('cls' if os.name == 'nt' else 'clear')  # Clear the terminal
                    print(frame)
                    time.sleep(speed)
    
        except KeyboardInterrupt:
            print("\nAnimation stopped.")  # Handle Ctrl+C interruption
        finally:
            os.system('cls' if os.name == 'nt' else 'clear') #Clear terminal at the end
    
    if __name__ == "__main__":
        animate_pikachu() # Start the animation
    

    Key improvements and explanations:

    • Animation Frames: The frames list now contains a series of string representations of Pikachu in slightly different running poses. These are carefully designed (using ASCII art) to give the illusion of movement.
    • os.system('cls' if os.name == 'nt' else 'clear'): This is crucial for creating the animation effect. It clears the terminal screen before each frame is printed. This is the technique for making things look like they're moving on the screen.
      • os.system() executes a shell command.
      • 'cls' is the command to clear the screen on Windows.
      • 'clear' is the command to clear the screen on Linux/macOS.
      • os.name == 'nt' checks if the operating system is Windows. This makes the code cross-platform.
    • time.sleep(speed): This pauses the execution of the script for a short amount of time (specified by speed in seconds) after each frame is printed. This controls the speed of the animation.
    • KeyboardInterrupt handling: The try...except block handles the KeyboardInterrupt exception, which is raised when the user presses Ctrl+C to stop the script. This prevents the script from crashing and allows you to gracefully exit the animation loop. A finally block ensures the screen is cleared even if the animation is stopped abruptly.
    • Clear Screen at End: os.system('cls' if os.name == 'nt' else 'clear') in finally block clears the terminal after animation is stopped.
    • if __name__ == "__main__":: This ensures that the animate_pikachu() function is only called when the script is run directly (not when it's imported as a module into another script).
    • Speed Control: The speed parameter to animate_pikachu() lets you easily adjust how fast the animation runs. A smaller speed value makes it faster.
    • Indefinite Loop: The while True: loop ensures the animation runs continuously until you interrupt it with Ctrl+C.
    • Comments and Docstrings: The code is well-commented and includes a docstring for the animate_pikachu function to explain what it does.

    How to run the script:

    1. Save: Save the code as a Python file (e.g., pikachu_animation.py).
    2. Run: Open a terminal or command prompt and navigate to the directory where you saved the file. Then, run the script using the command: python pikachu_animation.py

    You should see Pikachu running in your terminal window! Press Ctrl+C to stop the animation. You can modify the speed argument in the animate_pikachu() call to make it run faster or slower. You can also customize the animation frames to create different running poses or other animations.

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