gpt-4-1106-preview· openai
Suzhen/CodeChat
START OF PREVIOUS DISCUSSION END OF PREVIOUS DISCUSSION
- User
START OF PREVIOUS DISCUSSION END OF PREVIOUS DISCUSSION user: hi, make a python script that prints fibonacci numbers
- 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.