研究与设计分析作业(5)

it2025-10-28  6

{ "cells": [ { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "please provide a number:6\n", "True\n" ] } ], "source": [ "def foundnum(num:int,num_list:list=[3, 6, 2, 10, 3454, 5677])->bool:\n", " return bool(num in num_list)\n", "num = int(input('please provide a number:'))\n", "print(foundnum(num))" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "please provide a number:10\n", "1 1 2 3 5 8 13 21 34 55 " ] } ], "source": [ "def digui(n):\n", " if n==0 or n==1:\n", " return 1\n", " return digui(n-1) + digui(n-2)\n", "num = int(input('please provide a number:'))\n", "for x in range(num):\n", " print(digui(x),end=\" \")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.3" } }, "nbformat": 4, "nbformat_minor": 2 }
最新回复(0)