Friday, January 31, 2020

2.7 List Operations

Warm-up    2.7 - slice, append, pop, remove

  • Debrief warm-up

Lesson 2.7 Lists Part 1   

  1. Define and identify: slice, append, pop, remove;
  2. Slice a list;
  3. Add and remove elements from a list.
  • If you haven't already, read Section 2.5 List Operations
  • Slice Definition: Slicing is a list operation that gives back a list starting from the index to the left of the colon and going up to the index to the right of the colon. Note that slicing doesn't exist in Snap!
  • List Operation Summary Notes

www.google.com Lab 2.7 - Traversing and Setting up Tic-Tac-Toe

  1. Practice slicing, adding, and removing elements from some given lists;
  2. Create a single move Tic-Tac-Toe game
  3. Name your file Lab2.7_OneMoveTicTacToe.py
  Due Wednesday February 5, 2020 

Thursday, January 30, 2020

2.6 Introduction to Lists



Due Wednesday: 

  1. Lab 2.6_GameShow.py
  2. Choose a Quiz Theme (See Slides)
    -Write out questions and point valuation FIRST
  3. 2.5 Reading: List Operations
  4. Write out at least 5 quiz questions with point valuations

Monday, January 27, 2020

2.5 Triangle Lab

SSS Triangle Lab

Ask the user for the side length of a triangle.


  • Check if the sides can make a triangle. If they don't make a triangle, let the user know. 
  • If the sides can make a triangle, classify the triangle two different ways:
    • By its sides: is the triangle equilateralisosceles, or scalene ?
    • By its angles: is the triangle rightobtuse, or acute ?
    • Bonus: Report the area of the triangle.
    • Double Bonus: Report all the measure of the angle in the triangle. Research law of cosines for this task. 
  • When done, ask whether the user wants to run the code again. If they say no, stop the program. If they say anything else, run the program again. 
  • BEFORE YOU CODE, you must create pseudo-code!

If you get stuck:

The converse of the Pythagorean Theorem will help you classify a triangle by its angles. 



Test Input and Output

Sample Below:
Input:
Please give me three numbers representing the side lengths of a triangle.
Enter the shortest side: 3
Enter the second shortest side: 4
Enter the longest side: 5

Output:
Perimeter of the triangle is 12
This is a scalene right triangle.
BONUS! The area of this triangle is 6 square units.
DOUBLE BONUS!! This triangle has angle measures of 90.0, 53.13040235415599, and 36.86989764584 degrees. 

 Due Friday February 1, 2019



Friday, January 24, 2020

2.4 Conditional Execution of Code (2020)

Lesson 2.4   Conditionals


Goals:
1) Define and identify: if, else, elif, conditionals, flow of control 
2) Create chaining if statements 
3) Understand how conditional statements alter the flow of control of a program

Summary:
  • Conditional Statement Definition: Also known as an if statement. An if statement checks conditions and change the behavior of the program accordingly.
  • Conditional statements:
    • if statement chooses between executing code or not
    • if-else statement provides a choice between two code paths
    • if-elif-else statement provides a choice between 3 or more code paths

To Do after Lesson:
1)  Lab 2.4 - Can I Ride the Roller Coaster? (On Repl)
  • Name your file LastName_FirstName_Lab2.4_RollerCoaster
2) Read Section 2.3 Conditional execution

  Due Monday  January 27, 2020:
  1. Lab2.4_RollerCoster
  2. Read Section 2.3 Conditional execution
  3. Read Section 2.4 on lists

Thursday, January 23, 2020

2.3 Evaluating and Using Boolean Expressions



Today we will learn to evaluate a Boolean expression. 

We will compose Boolean expressions using and, or, not, <, <=, >, >=, and ==.


Due Friday January , 2020:

  • Lab 2.3 Driving Test, Can I be Senator?

Tuesday, January 21, 2020

2.2 Casting

Part I: Lesson Slides and Lab on Type Conversion (Casting)

2.2 Lesson Slides on Casting


Casting is the process of changing the data type of a a variable.

Today we will learn to evaluate a Boolean expression. We will compose Boolean expressions using and, or, not, <, <=, >, >=, and ==.

Lab 2.2 - Casting

  • Create a new folder in your workspace called Unit2
  • Your file will be called LastName_FirstName_Lab2.2_Casting.py
  • Remember to turn in on canvas as a py file. 

Part II: Snakify Lesson and Practice



  • Read lesson 2 Theory, and run examples in it (~10 minutes):



Practice these problems onf repl:



Part III: Tonight's Reading





For those of you that want to read ahead, the link for the full book is below!










 Due Friday January 25, 2019 

  • Lab 2.2
  • Snakify Reading, 3 problems (last digit, fractional part, digit after decimal point)
  • Reading 2.1 

Thursday, January 16, 2020

Uber-Importante: Print Formatting Lesson

Project01 Mad Libs Story Game - Introduction

  • Using Python, you will use variables, inputs/outputs, and printing to create a Mad Libs story game. You will need to plan out your Mad Lib before implementing it.
  • Mad Libs are a fun way to tell a story. The story is pre-written except for a few words. The user fills in the words before seeing the story. Then the story is read off with the user’s words mixed in!
  • Review Mad Libs Rubric
  • Name your project proj01MadLibs-vrs01.py
  • MadLibs Teacher Demo - Cloud09 file proj01MadLibs-vrs01.py

  Due Tuesday:  Jan 21, 2020 


Unit 01 Review for Quiz (refer back to the posted lessons and readings)


Definitions
  • Define: IDE, Python
  • Define: interpreter, string, integer, float, value, errors, console, expression
  • Define: script, print, run, output, variable
  • Define: comments, variable assignment, input
  • Review Assigned Readings and Slides
Skills:
  • Variable assignments
         x = 5
  • print statements with numbers
         
    print(x)
  • print statements with strings
         
    print ("The cat's name is ")
  • print statements with string concatenation     cat_name = 'Garfield'
         print("The cat's name is " + cat_name + '.')
  • Know how to use input. Know that the argument of input as well as the user's response is a string. 
 
          twoGuys = input('Who are those two guys?')
          print(twoGuys)                # Prints the user's response
          print( type(twoGuys) )    # str type
                userNumber = input("Feed me a delicious integer.")
                print(userNumber)             # Prints the user's response
                print( type(userNumber) ) # still a str type !!!
         

      Tuesday, January 14, 2020

      1.5 Error Handling in Python



      Goals: Discover what many of the error messages in Python mean.

      1. Take Notes on the Lesson Slides
      2. Classwork/Homework: Go through and complete the debugging tutorial: Know Your Error Messages.




        • To do your work, open a new python file that you work in as you go. Call it lastName_firstName_lab1.5_Debugging
        • Write down the problem number. Type out the error message provided. 
        • Write down how you fixed the error.
        • Write down the correct multiple choice at the end of the error.
        • Example below:

      Monday, January 13, 2020

      1.4 Variables and User Input

      Lesson 1.4 Slides


       Due Tuesday   January 14, 2020:
      1. Labs using string concatenation:
      • Hello Harry
      • Previous and Next 
      • Magic Genie 
      1. Reading:

      Friday, January 10, 2020

      1.3 Lesson Slides (2020)

      1.3 Using the Text Editor Lesson Slides


      Creating a New File


      1. To create a new text file, you can click My Repls, the the button +new replt
      2. Choose python as your chosen language and you're good to go.

      3. Generally, you type in scripts (programs of more than one line of code) into the text editor:
      4. TYPE this script into your text editor:
      # Script Header Information
      # Created by: last_name, first_name
      # Date: 12/18/2017
      # Description: My first Python script
      
      # Create a function that starts with any name. Indent 4 spaces after def.
      def greetings(name):
          print(name + "'s first Python script!" )
      
      # Create a another function just for fun
      def sayItaLot(nTimes):
          print("The world loves me !  " * nTimes )
      
      # Main Script. Call the previously defined functions 
      
      print("hello world")
      
      greetings("Dave")
      
      sayItaLot(5)
      
      3. Replt.it should save your work as long as you have internet access. Generally, however, you should press Ctrl-s to save the file. You will now save this as a python file. This will allow the text editor to interpret your text as python keywords.

      Parts of the IDE










      1. File tree
      2. Console/terminal
      3. Editor

      Due Monday January 13, 2020: 
      1. In class: knowledge of how to run a script via repl
      2. Classwork/Homework: 
        • Repl.it Assignments:
          • Read Snakify Lesson 1 Theory and then complete these exercises on repl.it:
          • Sum of Three Numbers
          • Area of a right triangle
          • Apple Sharing

      Thursday, January 9, 2020

      Lesson 1.2 Interactive Mode Slides

      • The right half of the repl.it interface is called a console. The console is a place where you can interact with a program. It can also be called a shell or a terminal.
      • The interpreter runs Python code. In most terminals, to run the Python interpreter program, type python3 into the terminal.
      • In repl, when you choose to create a python3 program, the console will already be running python 3.x .
      • In most consoles, type exit() or Ctrl-D to exit the interpreter and return to the $ command shell.
      • Python is a text-based programming language, uses tabbing/indentation to control execution, and is known for its readability.

       Lab 1.2 Part 1 - Using the Python Interpreter in Interactive Mode

      Use the interpreter to evaluate expressions
      • If you haven't already, read Section 1.1 Values and Types
      • Lab 1.2 worksheet: make a copy of the lab. Type in your answers and keep worksheet for your notes. Please add to these notes as well. 
      • float: a data type, number with a decimal point (e.g. 3.0).
      • integer: a data type, number without a decimal point (e.g. 3).
      • string: a data type, characters surrounded in single or double quotes. Strings can be concatenated (combined) using the + operator .
      • expression: a combination of values and operators (and variables). Order of Operations is the same as what you have learned in math class.
        Due Friday  January 10, 2020:
      1. Lab 1.2 Worksheet. Make a copy. Submit on canvas.
      2. Reading 1.1 Values and Types
      3. Reading 1.2 Variables
      4. Reading 1.3 Errors and Debugging




      Tuesday, January 7, 2020


       Lesson 1.1 repl.it Coding Environment

      To code in any language, an Integrated Development Environment (IDE) is needed. is a visual drag/drop IDE. An IDE is an application that allows you to create, edit, save, and run programs.  To code in Python, we can't use drag/drop anymore. It is a language that must be typed into a text editor and interpreted by the computer using a program.
      • We will be using an online IDE called repl.  Follow the intstructions to sign up for a repl account to start coding in Python.
      • Most of our homework from now on will involve finishing in class labs, doing reading, and completing projects. 
      • Your required (free) text book is Think Python, 2nd Edition by Green Tea Press. Although the author politely asks for a few dollars to  contriubte to his work, you are by no means required to send him money. Here is the link to download the pdf of the whole textbook
      • Think Python is very well written with terrific examples. I highly recommend you read ahead and in between the required reading that I assign. 
        Due Thursday January 9, 2020:
      1. Sign up for repl account (~5 minutes)
      2. Complete the hello world assignment (found under the assignment tab) (~5 minutes)
      3. Read Required Reading 1.1 Values and Types (~15 minutes) and take notes.
      4. Read Required Reading 1.2 Variable Names and Keywords (~15 minutes) and take notes.

      Blog information move to Google Doc

      Hello All, Moving forward, please find all information about the class that you used to find on a live google doc agenda. The link is foun...