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: hi, make a python script that prints fibonacci numbers

  2. Assistant

    Certainly! Below is a simple Python script that prints Fibonacci numbers. When run, it will prompt you to enter the number of terms you would like to see in the Fibonacci sequence.

    def fibonacci(n):
        a, b = 0, 1
        for i in range(n):
            print(a, end=" ")
            a, b = b, a + b
    
    n_terms = int(input("How many Fibonacci numbers would you like to see? "))
    print(f"Showing the first {n_terms} Fibonacci numbers:")
    fibonacci(n_terms)
    

    To use this script, copy it into a Python (.py) file or execute it in an interactive Python environment, then enter the number of Fibonacci sequence terms you wish to generate when prompted.