diff --git a/f22/andy_lec_notes/lec05_Sep16_UsingFunctions/.ipynb_checkpoints/lec_05_template-checkpoint.ipynb b/f22/andy_lec_notes/lec05_Sep16_UsingFunctions/.ipynb_checkpoints/lec_05_template-checkpoint.ipynb deleted file mode 100644 index f9b7c2fa82746a2736a5d975457eb00eb9a152aa..0000000000000000000000000000000000000000 --- a/f22/andy_lec_notes/lec05_Sep16_UsingFunctions/.ipynb_checkpoints/lec_05_template-checkpoint.ipynb +++ /dev/null @@ -1,417 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [], - "source": [ - "# Warmup:\n", - "\n", - "# Use the ** operator to calculate the square root of 17\n", - "# Use type to print out the type of the answer\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### September 17: Expressions and Variables\n", - "Learning Objectives:\n", - "- 5.1 Evaluate Expressions\n", - "- by identifying operators and operands\n", - "- by identifying literal values and variables\n", - "- by identifying the correct order of operations\n", - "\n", - "\n", - "5.2 Write assignment statements with proper syntax\n", - "- Start with a variable name that follows proper rules for variables\n", - "- Use a single equals sign\n", - "- Finish with an expression\n", - " \n", - " \n", - "5.3 Define, give examples of, and identify 3 kinds of errors\n", - "- Syntax error\n", - "- Runtime error\n", - "- Semantic error\n", - " \n", - " \n", - "5.4 Write Python code that computes with strings ints, floats, and Boolean types" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [], - "source": [ - "# Trick expression #1: What will this evaluate to:\n", - "# 1+1 ==2 or 3 ** 10000000 > 2 ** 20000000" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [], - "source": [ - "# 3 ** 10000000 > 2 ** 20000000" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [], - "source": [ - "# 1 + 1 == 2 or 4 / 0" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [], - "source": [ - "# 4 / 0 or 1 + 1 == 2 " - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [], - "source": [ - "# False or True" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [], - "source": [ - "# These examples might seem weird but they preview the kinds of errors\n", - "# students make in their code" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [], - "source": [ - "# False or \"hi\"" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [], - "source": [ - "# 3 + 4 == 7 or 6 # Incorrect conditions" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": {}, - "outputs": [], - "source": [ - "# 3 + 4 == 6 or 7 # Incorrect conditions" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": {}, - "outputs": [], - "source": [ - "# 3 + 4 == 6 or 8 # Incorrect conditions" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": {}, - "outputs": [], - "source": [ - "# 3 + 4 == 6 or 3 + 4 == 7 #Correct conditions" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "10\n" - ] - } - ], - "source": [ - "x = 10\n", - "print(x)" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "11" - ] - }, - "execution_count": 14, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "x + 1" - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "13\n" - ] - } - ], - "source": [ - "x = x + 3\n", - "print(x)" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "metadata": {}, - "outputs": [], - "source": [ - "x += 3" - ] - }, - { - "cell_type": "code", - "execution_count": 17, - "metadata": {}, - "outputs": [], - "source": [ - "x -= 1\n" - ] - }, - { - "cell_type": "code", - "execution_count": 18, - "metadata": {}, - "outputs": [], - "source": [ - "# 5 = x # Syntax error" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": 19, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "0\n", - "0\n", - "0\n" - ] - } - ], - "source": [ - "# int demo\n", - "# Print out hours, minutes, and seconds \n", - "seconds = 12345\n", - "\n", - "hours = 0\n", - "print(hours)\n", - "\n", - "seconds = 0\n", - "\n", - "minutes = 0\n", - "print(minutes)\n", - "\n", - "seconds = 0\n", - "print(seconds)" - ] - }, - { - "cell_type": "code", - "execution_count": 20, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "7612.255042662042\n" - ] - } - ], - "source": [ - "# float demo\n", - "# Compound growth\n", - "start = 1000\n", - "interest = 7\n", - "years = 30\n", - "\n", - "yearly_mult = 1 + interest / 100\n", - "final = start * (yearly_mult ** years)\n", - "print(final)" - ] - }, - { - "cell_type": "code", - "execution_count": 21, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Alice: ||||||||||\n", - "bob: ||||||||\n", - "Alice: ||||||||||\n", - "bob: ||||||||\n" - ] - } - ], - "source": [ - "# str demo\n", - "# Alice vs Bob\n", - "\n", - "player1_name = 'Alice'\n", - "player2_name = 'bob'\n", - "\n", - "player1_score = 10\n", - "player2_score = 8\n", - "\n", - "#Scores are difficult to compare\n", - "print(player1_name + ': ' + '|' * player1_score)\n", - "print(player2_name + ': ' + '|' * player2_score)\n", - "\n", - "#Assuming name has a maximum of 9 characters\n", - "#Now scores are easier to read and compare\n", - "print(player1_name + ': ' + \" \" * (9 - len(player1_name)) + '|' * player1_score)\n", - "print(player2_name + ': ' + \" \" * (9 - len(player2_name)) + '|' * player2_score)\n" - ] - }, - { - "cell_type": "code", - "execution_count": 22, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "you may continue: True\n" - ] - } - ], - "source": [ - "# bool example\n", - "age = 10\n", - "valid = 0 <= age <= 100\n", - "print(\"you may continue: \" + str(valid))" - ] - }, - { - "cell_type": "code", - "execution_count": 23, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "you may continue: False\n" - ] - } - ], - "source": [ - "# bool example\n", - "age = 110\n", - "valid = 0 <= age <= 100\n", - "print(\"you may continue: \" + str(valid))" - ] - } - ], - "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.9.7" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -}