Skip to content
TheChatArchiveThe Chat Archive
gpt-4-1106-preview· openaiHugging Face Suzhen/CodeChat

START OF PREVIOUS DISCUSSION END OF PREVIOUS DISCUSSION

  1. User

    START OF PREVIOUS DISCUSSION END OF PREVIOUS DISCUSSION user: make a python script that prints fibo numbers

  2. Assistant

    Sure! Here is a simple python script that prints out Fibonacci numbers. The Fibonacci sequence starts with two numbers, 0 and 1, and each subsequent number is the sum of the previous two.

    # Function to print n Fibonacci numbers
    def fibo(n):
        a, b = 0, 1
        for i in range(n):
            print(a, end=' ')
            a, b = b, a+b
    
    # Ask the user for the number of terms
    num_terms = int(input("Enter the number of Fibonacci numbers to print: "))
    
    # Call the function to print the Fibonacci series
    fibo(num_terms)
    

    When you run this script, it asks for the number of Fibonacci numbers you would like to see, and then it prints that many numbers from the Fibonacci sequence. If you want to see the first 10 Fibonacci numbers, you would enter 10 when the script prompts you for input.

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