Skip to content
TheChatArchiveThe Chat Archive
OpenChatopenchat-3.5· OpenChatHugging Face Arena Human Preference 55K

write code to output digits of pi

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with gpt-4-1106-preview’s answer.
  1. User

    write code to output digits of pi

  2. OpenChat Assistant

    Here's a Python code snippet to output the first 100 digits of Pi:

    import math
    
    def print_pi_digits(n):
        pi = math.pi
        for _ in range(n):
            print(int(pi * 10**10) % 10)
    
    print_pi_digits(100)
    

    This code imports the math module, defines a function print_pi_digits that takes a parameter n (the number of digits to print), and prints out the digits of Pi up to the required number of digits. The math.pi constant is used to calculate the digits, and the print function is used to output each digit. The code is then executed by calling print_pi_digits(100) to print the first 100 digits of Pi.

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