gpt-4o-mini-2024-07-18· OpenAI
WildChat-4.8M (AI2)
make 10 line python code
- User
make 10 line python code
- Assistant
Sure! Here’s a simple Python program that generates and prints the Fibonacci sequence up to a specified number of terms.
def fibonacci(n): fib_sequence = [0, 1] for i in range(2, n): next_value = fib_sequence[-1] + fib_sequence[-2] fib_sequence.append(next_value) return fib_sequence[:n] num_terms = int(input("Enter the number of terms: ")) if num_terms <= 0: print("Please enter a positive integer.") else: print("Fibonacci sequence:") print(fibonacci(num_terms))This code prompts the user for the number of Fibonacci terms to generate, calculates the sequence, and prints it.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.