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: make a short python script for fibo numbers
- Assistant
Certainly! Below is a simple Python script that generates Fibonacci numbers. In this example, it generates the first 10 Fibonacci numbers, but you can adjust
num_termsto generate as many as you want:def fibonacci(n): fib_sequence = [0, 1] for i in range(2, n): next_fib = fib_sequence[-1] + fib_sequence[-2] fib_sequence.append(next_fib) return fib_sequence num_terms = 10 fibs = fibonacci(num_terms) print(f"The first {num_terms} Fibonacci numbers are: {fibs}")Just run this script in your Python environment to see the first 10 Fibonacci numbers. If you want to generate a different length of the Fibonacci sequence, change the
num_termsvariable to your desired length.