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 simple python script that pritns fibo numbers
- Assistant
Sure, here's a basic Python script that will print the Fibonacci numbers up to a certain limit, defined by the variable
upper_limit. A Fibonacci sequence starts with 0 and 1, and every number following is the sum of the two preceding ones.python# Define the upper limit upper_limit = 10 # Function to print Fibonacci numbers def print_fibonacci(upper_limit): a, b = 0, 1 while a < upper_limit: print(a, end=' ') a, b = b, a + b # Call the function print_fibonacci(upper_limit)This script will print the Fibonacci numbers starting from 0 until it reaches or surpasses the
upper_limitwhich is set to 10 in this case. Modify theupper_limitvariable as needed to print more or less Fibonacci numbers. To use this script, save it as a.pyfile and run it with your Python interpreter.