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

it2025-10-29  2

{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Provide a word to search for vowels:aeiou\n", "a was found 1 time(s).\n", "e was found 1 time(s).\n", "i was found 1 time(s).\n", "o was found 1 time(s).\n", "u was found 1 time(s).\n" ] } ], "source": [ "vowels=['a','e','i','o','u']\n", "word=input(\"Provide a word to search for vowels:\")\n", "found={}\n", "found['a']=0\n", "found['e']=0\n", "found['i']=0\n", "found['o']=0\n", "found['u']=0\n", "for letter in word:\n", " if letter in vowels:\n", " found[letter] +=1\n", "for k, v in sorted(found.items()):\n", " print(k, 'was found', v, 'time(s).')" ] }, { "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)