{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# CSE 160 Section 1 Problems" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Problem 1. \n", "\n", "**For each expression, write the resultant value and the data type of the value (for instance, Integer)**\n", "```\n", "a. 42\n", "b. 42+91/3.0\n", "c. 42/5+2.0\n", "d. True\n", "e. 42<45\n", "f. not42<91\n", "g. \"May the force be with you.\"\n", "h. float(3) < 9\n", "```\n" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "# Code cell for testing solutions to Problem 1\n", "# Hint: type() may be useful (e.g. type(42))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Problem 2. \n", "**For each list write an equivalent range() call. For each range() call give the corresponding list.**\n", "```\n", "a. [0,1,2,3] \n", "b. [-4, -3, -2, -1, 0]\n", "c. range(0, 10, 2)\n", "d. range(2, 11, 3)\n", "e. [25, 20, 15, 10, 5, 0]\n", "f. range(1000, -100, -100)\n", "```" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Code cell for testing solutions to Problem 2" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Problem 3. \n", "**Write the output to the following program:**\n", "```python\n", "for value in [1, 3, 5]:\n", " print (value + value ** 2)\n", "```\n", " " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Code cell for testing solutions to Problem 3\n", "# Please try to figure out the expected output before testing the code." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Problem 4. \n", "**Write a for loop that will print the result of multiplying 3 by the numbers 8 through 12. The example solution is two lines long. Your output should read:**\n", "\n", "``` \n", "24 \n", "27 \n", "30 \n", "33 \n", "36\n", "```" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Code cell for testing solutions to Problem 4" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Problem 5. \n", "**Write the output to the following program:**\n", "\n", "```python\n", "for i in [1, 2, 3]:\n", " for j in [1, 2, 3]:\n", " print (i + j)\n", "```" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Code cell for testing solutions to Problem 5\n", "# Please try to figure out the expected output before testing the code." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Problem 6. \n", "**Write the output to the following program:**\n", "\n", "```python\n", " sum=0 \n", " for i in [1,2,3]:\n", " for j in [1,2, 3]: \n", " sum=sum+ i\n", " print (sum)\n", "```" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Code cell for testing solutions to Problem 6\n", "# Please try to figure out the expected output before testing the code." ] } ], "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.7.1" } }, "nbformat": 4, "nbformat_minor": 2 }