From 4a5bf6a38f44be26c9f77af9c881fb7bfd706894 Mon Sep 17 00:00:00 2001 From: Wanying Xu <94760781+OliviaCoding@users.noreply.github.com> Date: Sun, 3 Aug 2025 23:03:23 -0400 Subject: [PATCH 1/5] Create Wanying_Xu_Week2_Homework --- homeworks/Wanying_Xu_Week2_Homework | 217 ++++++++++++++++++++++++++++ 1 file changed, 217 insertions(+) create mode 100644 homeworks/Wanying_Xu_Week2_Homework diff --git a/homeworks/Wanying_Xu_Week2_Homework b/homeworks/Wanying_Xu_Week2_Homework new file mode 100644 index 0000000..b5e834b --- /dev/null +++ b/homeworks/Wanying_Xu_Week2_Homework @@ -0,0 +1,217 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## ❌ DO NOT EDIT - MAKE A COPY\n", + "# Q1: Alphabet Slices\n", + "* Store the first ten letters of the alphabet in a list.\n", + "* Use a slice to print out the first three letters of the alphabet.\n", + "* Use a slice to print out any three letters from the middle of your list." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Solve Alphabet slices here. \n", + "## Extra Credit: Do this without 'hard coding' the alpahbet.\n", + "\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Q2: Covert all the rapper names to title case and save them into a new different list. \n", + "Example: **lil wayne** becomes **Lil Wayne**" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Solve rapper names here\n", + "rappers = ['lil wayne', 'nicki minaj', 'drake']\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Q3: Write a function that takes a number and returns:\n", + "* True if the input number is even.\n", + "* False if the input number is odd." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Solve problem here\n", + "\n", + "def even_odd(lst):\n", + " pass # replace this with your code\n", + " # return something" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Q4: Find the sum and the average of this list of numbers.\n", + "\n", + "Try doing this using a loop. Then try doing this without using a loop. " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Solve problem here:\n", + "\n", + "my_list = [1, 5, 10, 55, 88, 44, 42, 50, 20, 38]\n", + "list_sum = ???\n", + "list_avg = ???\n", + "\n", + "\n", + "# Keep this as your last line in this cell.\n", + "print(list_sum, list_average)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Q5: \n", + "## Write a function that takes a list and returns a new list that has all the duplicates removed.\n", + "\n", + "Example input and expected output:\n", + "- input = `[\"Michele\", \"Robin\", \"Sara\", \"Michele\"]`\n", + "- expected output = `['Michele', 'Robin', 'Sara']`\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Solve problem here:\n", + "\n", + "names = [\"Michele\", \"Robin\", \"Sara\", \"Michele\"]\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Q6: Write a function that takes a list of numbers \n", + "(for example, `a = [5, 10, 15, 20, 25]`) and returns a new list of only the first and last elements of the given list.\n", + "\n", + "Example input and expected output:\n", + "- input = `[5, 10, 15, 20, 25]`\n", + "- expected output = `[5, 25]`" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Solve problem here:\n", + "input_list = [5, 10, 99, 20, 25]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Q7: \n", + "## Implement a function that takes as input three variables, and returns the largest of the three. \n", + "### Try doing this without using the `max()` function!\n", + "\n", + "_**Note:** all three input numbers will always be different, no need to account for a tie._\n", + "\n", + "Example input and expected output:\n", + "- input: `your_function(1, 5, 10)`\n", + "- expected output: `10`" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Solve Problem here:\n", + "\n", + "def my_max(a, b, c):\n", + " # Fill in your code below and return max value of a, b, c\n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Test to see if your function works properly.\n", + "my_max(1, 5, 10)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Q8: Write a function that takes a number as input and returns the following:\n", + "* If the input is divisible by three, return `'fizz'`\n", + "* If the input is divisible by five, return `'buzz'`\n", + "* If the input is divisible by three and by five, return `'fizzbuzz'`\n", + "* If the input is not divisible by three or five, return `None`." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Solve Problem fizzbuzz here:\n" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "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.12.4" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} From 0407bc85bdba21f5097166ed36103e29f9995764 Mon Sep 17 00:00:00 2001 From: Wanying Xu <94760781+OliviaCoding@users.noreply.github.com> Date: Sun, 3 Aug 2025 23:13:57 -0400 Subject: [PATCH 2/5] Delete homeworks/Wanying_Xu_Week2_Homework --- homeworks/Wanying_Xu_Week2_Homework | 217 ---------------------------- 1 file changed, 217 deletions(-) delete mode 100644 homeworks/Wanying_Xu_Week2_Homework diff --git a/homeworks/Wanying_Xu_Week2_Homework b/homeworks/Wanying_Xu_Week2_Homework deleted file mode 100644 index b5e834b..0000000 --- a/homeworks/Wanying_Xu_Week2_Homework +++ /dev/null @@ -1,217 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## ❌ DO NOT EDIT - MAKE A COPY\n", - "# Q1: Alphabet Slices\n", - "* Store the first ten letters of the alphabet in a list.\n", - "* Use a slice to print out the first three letters of the alphabet.\n", - "* Use a slice to print out any three letters from the middle of your list." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Solve Alphabet slices here. \n", - "## Extra Credit: Do this without 'hard coding' the alpahbet.\n", - "\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Q2: Covert all the rapper names to title case and save them into a new different list. \n", - "Example: **lil wayne** becomes **Lil Wayne**" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Solve rapper names here\n", - "rappers = ['lil wayne', 'nicki minaj', 'drake']\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Q3: Write a function that takes a number and returns:\n", - "* True if the input number is even.\n", - "* False if the input number is odd." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Solve problem here\n", - "\n", - "def even_odd(lst):\n", - " pass # replace this with your code\n", - " # return something" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Q4: Find the sum and the average of this list of numbers.\n", - "\n", - "Try doing this using a loop. Then try doing this without using a loop. " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Solve problem here:\n", - "\n", - "my_list = [1, 5, 10, 55, 88, 44, 42, 50, 20, 38]\n", - "list_sum = ???\n", - "list_avg = ???\n", - "\n", - "\n", - "# Keep this as your last line in this cell.\n", - "print(list_sum, list_average)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Q5: \n", - "## Write a function that takes a list and returns a new list that has all the duplicates removed.\n", - "\n", - "Example input and expected output:\n", - "- input = `[\"Michele\", \"Robin\", \"Sara\", \"Michele\"]`\n", - "- expected output = `['Michele', 'Robin', 'Sara']`\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Solve problem here:\n", - "\n", - "names = [\"Michele\", \"Robin\", \"Sara\", \"Michele\"]\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Q6: Write a function that takes a list of numbers \n", - "(for example, `a = [5, 10, 15, 20, 25]`) and returns a new list of only the first and last elements of the given list.\n", - "\n", - "Example input and expected output:\n", - "- input = `[5, 10, 15, 20, 25]`\n", - "- expected output = `[5, 25]`" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Solve problem here:\n", - "input_list = [5, 10, 99, 20, 25]" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Q7: \n", - "## Implement a function that takes as input three variables, and returns the largest of the three. \n", - "### Try doing this without using the `max()` function!\n", - "\n", - "_**Note:** all three input numbers will always be different, no need to account for a tie._\n", - "\n", - "Example input and expected output:\n", - "- input: `your_function(1, 5, 10)`\n", - "- expected output: `10`" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Solve Problem here:\n", - "\n", - "def my_max(a, b, c):\n", - " # Fill in your code below and return max value of a, b, c\n", - " " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Test to see if your function works properly.\n", - "my_max(1, 5, 10)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Q8: Write a function that takes a number as input and returns the following:\n", - "* If the input is divisible by three, return `'fizz'`\n", - "* If the input is divisible by five, return `'buzz'`\n", - "* If the input is divisible by three and by five, return `'fizzbuzz'`\n", - "* If the input is not divisible by three or five, return `None`." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Solve Problem fizzbuzz here:\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "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.12.4" - } - }, - "nbformat": 4, - "nbformat_minor": 4 -} From af7bf2997ac0e60e65733466671ddc136972cdbf Mon Sep 17 00:00:00 2001 From: Wanying Xu <94760781+OliviaCoding@users.noreply.github.com> Date: Sun, 3 Aug 2025 23:15:06 -0400 Subject: [PATCH 3/5] Create WX_week2_hw.ipynb --- homeworks/WX_week2_hw.ipynb | 1 + 1 file changed, 1 insertion(+) create mode 100644 homeworks/WX_week2_hw.ipynb diff --git a/homeworks/WX_week2_hw.ipynb b/homeworks/WX_week2_hw.ipynb new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/homeworks/WX_week2_hw.ipynb @@ -0,0 +1 @@ + From cc6df0bb6664a8d64eab66339b87504989b91e7c Mon Sep 17 00:00:00 2001 From: Wanying Xu <94760781+OliviaCoding@users.noreply.github.com> Date: Sun, 3 Aug 2025 23:23:12 -0400 Subject: [PATCH 4/5] Update WX_week2_hw.ipynb --- homeworks/WX_week2_hw.ipynb | 218 +++++++++++++++++++++++++++++++++++- 1 file changed, 217 insertions(+), 1 deletion(-) diff --git a/homeworks/WX_week2_hw.ipynb b/homeworks/WX_week2_hw.ipynb index 8b13789..b5e834b 100644 --- a/homeworks/WX_week2_hw.ipynb +++ b/homeworks/WX_week2_hw.ipynb @@ -1 +1,217 @@ - +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## ❌ DO NOT EDIT - MAKE A COPY\n", + "# Q1: Alphabet Slices\n", + "* Store the first ten letters of the alphabet in a list.\n", + "* Use a slice to print out the first three letters of the alphabet.\n", + "* Use a slice to print out any three letters from the middle of your list." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Solve Alphabet slices here. \n", + "## Extra Credit: Do this without 'hard coding' the alpahbet.\n", + "\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Q2: Covert all the rapper names to title case and save them into a new different list. \n", + "Example: **lil wayne** becomes **Lil Wayne**" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Solve rapper names here\n", + "rappers = ['lil wayne', 'nicki minaj', 'drake']\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Q3: Write a function that takes a number and returns:\n", + "* True if the input number is even.\n", + "* False if the input number is odd." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Solve problem here\n", + "\n", + "def even_odd(lst):\n", + " pass # replace this with your code\n", + " # return something" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Q4: Find the sum and the average of this list of numbers.\n", + "\n", + "Try doing this using a loop. Then try doing this without using a loop. " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Solve problem here:\n", + "\n", + "my_list = [1, 5, 10, 55, 88, 44, 42, 50, 20, 38]\n", + "list_sum = ???\n", + "list_avg = ???\n", + "\n", + "\n", + "# Keep this as your last line in this cell.\n", + "print(list_sum, list_average)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Q5: \n", + "## Write a function that takes a list and returns a new list that has all the duplicates removed.\n", + "\n", + "Example input and expected output:\n", + "- input = `[\"Michele\", \"Robin\", \"Sara\", \"Michele\"]`\n", + "- expected output = `['Michele', 'Robin', 'Sara']`\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Solve problem here:\n", + "\n", + "names = [\"Michele\", \"Robin\", \"Sara\", \"Michele\"]\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Q6: Write a function that takes a list of numbers \n", + "(for example, `a = [5, 10, 15, 20, 25]`) and returns a new list of only the first and last elements of the given list.\n", + "\n", + "Example input and expected output:\n", + "- input = `[5, 10, 15, 20, 25]`\n", + "- expected output = `[5, 25]`" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Solve problem here:\n", + "input_list = [5, 10, 99, 20, 25]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Q7: \n", + "## Implement a function that takes as input three variables, and returns the largest of the three. \n", + "### Try doing this without using the `max()` function!\n", + "\n", + "_**Note:** all three input numbers will always be different, no need to account for a tie._\n", + "\n", + "Example input and expected output:\n", + "- input: `your_function(1, 5, 10)`\n", + "- expected output: `10`" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Solve Problem here:\n", + "\n", + "def my_max(a, b, c):\n", + " # Fill in your code below and return max value of a, b, c\n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Test to see if your function works properly.\n", + "my_max(1, 5, 10)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Q8: Write a function that takes a number as input and returns the following:\n", + "* If the input is divisible by three, return `'fizz'`\n", + "* If the input is divisible by five, return `'buzz'`\n", + "* If the input is divisible by three and by five, return `'fizzbuzz'`\n", + "* If the input is not divisible by three or five, return `None`." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Solve Problem fizzbuzz here:\n" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "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.12.4" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} From 451e73c2b2c1c74f50dbb733829a1c3a4e058c52 Mon Sep 17 00:00:00 2001 From: Wanying Xu <94760781+OliviaCoding@users.noreply.github.com> Date: Mon, 4 Aug 2025 03:52:28 +0000 Subject: [PATCH 5/5] completed week 2 homework --- homeworks/WX_week2_hw.ipynb | 198 ++++++++++++++++++++++++++++++------ 1 file changed, 168 insertions(+), 30 deletions(-) diff --git a/homeworks/WX_week2_hw.ipynb b/homeworks/WX_week2_hw.ipynb index b5e834b..997977a 100644 --- a/homeworks/WX_week2_hw.ipynb +++ b/homeworks/WX_week2_hw.ipynb @@ -4,7 +4,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## ❌ DO NOT EDIT - MAKE A COPY\n", + "## Wanying Xu's Week 2 Homework\n", "# Q1: Alphabet Slices\n", "* Store the first ten letters of the alphabet in a list.\n", "* Use a slice to print out the first three letters of the alphabet.\n", @@ -13,14 +13,26 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 23, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['a', 'b', 'c']\n", + "['d', 'e', 'f']\n" + ] + } + ], "source": [ "# Solve Alphabet slices here. \n", "## Extra Credit: Do this without 'hard coding' the alpahbet.\n", "\n", - "\n" + "letters = [chr(i) for i in range (ord('a'), ord('a')+10)]\n", + "\n", + "print(letters[:3])\n", + "print(letters[3:6])\n" ] }, { @@ -33,12 +45,26 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 24, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['Lil Wayne', 'Nicki Minaj', 'Drake']\n" + ] + } + ], "source": [ "# Solve rapper names here\n", - "rappers = ['lil wayne', 'nicki minaj', 'drake']\n" + "rappers = ['lil wayne', 'nicki minaj', 'drake']\n", + "title_rappers = []\n", + "\n", + "for rapper in rappers:\n", + " title_rappers.append(str.title(rapper))\n", + " \n", + "print(title_rappers)" ] }, { @@ -52,15 +78,28 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 25, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "False\n", + "True\n" + ] + } + ], "source": [ "# Solve problem here\n", "\n", "def even_odd(lst):\n", - " pass # replace this with your code\n", - " # return something" + " if lst % 2 == 0:\n", + " return True\n", + " return False\n", + "\n", + "print(even_odd(3))\n", + "print(even_odd(4))" ] }, { @@ -74,19 +113,27 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 26, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "353 35.3\n" + ] + } + ], "source": [ "# Solve problem here:\n", "\n", "my_list = [1, 5, 10, 55, 88, 44, 42, 50, 20, 38]\n", - "list_sum = ???\n", - "list_avg = ???\n", "\n", + "list_sum = sum(my_list)\n", + "list_avg = list_sum / len(my_list)\n", "\n", "# Keep this as your last line in this cell.\n", - "print(list_sum, list_average)" + "print(list_sum, list_avg)" ] }, { @@ -103,13 +150,31 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 27, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['Michele', 'Robin', 'Sara']\n" + ] + } + ], "source": [ "# Solve problem here:\n", "\n", - "names = [\"Michele\", \"Robin\", \"Sara\", \"Michele\"]\n" + "def unique(lst):\n", + " unique = []\n", + "\n", + " for l in lst:\n", + " if l not in unique:\n", + " unique.append(l)\n", + " \n", + " return unique\n", + "\n", + "names = [\"Michele\", \"Robin\", \"Sara\", \"Michele\"]\n", + "print(unique(names))\n" ] }, { @@ -126,12 +191,30 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 28, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[5, 25]\n" + ] + } + ], "source": [ "# Solve problem here:\n", - "input_list = [5, 10, 99, 20, 25]" + "def first_last(lst):\n", + " res = []\n", + "\n", + " res.append(lst[0])\n", + " res.append(lst[len(lst) - 1])\n", + "\n", + " return res\n", + "\n", + "input_list = [5, 10, 99, 20, 25]\n", + "\n", + "print(first_last(input_list))\n" ] }, { @@ -151,7 +234,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 29, "metadata": {}, "outputs": [], "source": [ @@ -159,14 +242,33 @@ "\n", "def my_max(a, b, c):\n", " # Fill in your code below and return max value of a, b, c\n", - " " + " max = a\n", + "\n", + " if b > max:\n", + " max = b\n", + " \n", + " if c > max:\n", + " max = c\n", + " \n", + " return max" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 30, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "10" + ] + }, + "execution_count": 30, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "# Test to see if your function works properly.\n", "my_max(1, 5, 10)" @@ -185,12 +287,48 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 31, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "fizz\n", + "buzz\n", + "fizzbuzz\n", + "None\n" + ] + } + ], "source": [ - "# Solve Problem fizzbuzz here:\n" + "# Solve Problem fizzbuzz here:\n", + "def fizzbuzz(num):\n", + " if num % 3 == 0 and num % 5 != 0:\n", + " return 'fizz'\n", + "\n", + " elif num % 5 == 0 and num % 3 != 0:\n", + " return 'buzz'\n", + " \n", + " elif num % 3 == 0 and num % 5 == 0:\n", + " return 'fizzbuzz'\n", + " \n", + " else:\n", + " return None\n", + " \n", + "print(fizzbuzz(3))\n", + "print(fizzbuzz(5))\n", + "print(fizzbuzz(15))\n", + "print(fizzbuzz(16))\n", + "\n" ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { @@ -209,7 +347,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.12.4" + "version": "3.12.1" } }, "nbformat": 4,