Only this pageAll pages
Powered by GitBook
1 of 48

Room112.TextBasedProgrammimg

Loading...

Unit 1

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Unit 2

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Proficiency Scale

This is the AP CSP Convesion from a Proficiency Grade to Numeric Grade

Unit 1. Standards

Written Response

ACT: 24-27 practice using academic and content-specific terms

When you are finished - compose 3-5 complete senctence response to each prompt using college level techncial writing and submit according to your instructions

AI For Oceans

These materials developed by code.org

Watch this video to get an overview of Machine Learning and AI

No work your way through these activities

Feature Extration in Machine Learning

Room112.TextBased Programming

Mary Clair Wright, NBCT

You Belong in the Room

List of Standards Taught and Assessed with this Curriculum

Functions With Strings

Write a python function named pasttense that accepts a string called verb as an input and displays the original verb and the verb with an "ed" added onto the end. See the function header and sample output below.

pasttense(verb):
    #body of the function goes here
    

Sample Output:
The past tense of talk is talked.

String Basics

A string in Python is a sequence of characters. It is a derived data type. Strings are immutable. This means that once defined, they cannot be changed

How can we make a new line, like hitting the enter key when typing?

This is an example of a special character - where 2 digits work together to do one thing

If you see this character in a string, that means that the current line ends at that point and a new line starts right after it

Notice the \n is a different color than the string
These are all the basic escape sequences

Strings and Variables

x = "Python is "
y = "awesome"
z =  x + y
print(z)
a = "Hello"
b = "World"
c = a + b
print(c)

Can you add a space? What doesn't Mrs. Wright Like about these variable names?

Storing Data in Variables

Variables: dedicated memory to store data. Named by the programmer, the name serves as a reference point or provides directions for the program to the values stored

Today we are going to use the python visualizer so that you can "see" the memory!

Data Ouput & Python Functions

To display information on the screen (or console) to the user we will uses the print command

Python Functions

Notes Together

Escape Sequence Assignment

1.2 Escape Sequences

  1. create a variable called firstLetter and store the first letter of your last name as a string. The print the value stored is first letter surrounded by '. For example, I would display 'W'

  2. print “Practice is not the thing you do once you are good. It is the thing you do that makes you good.” - Malcolm Gladwell Note: you need to display the “ “.

  3. display your first name and last name on one line together with your date of birth on another line and indented using only one print command

  4. create a function called yearAgan(y) that accepts the numeric year (for example "1985") as the input y and prints the following "It is 1985 all over again"

  5. Write one print statement that produces the following output:

    / \ // \\ /// \\\
  6. create a function spikey() that has no value passed in, but when it is called produces the following output. Each line of output should be its own print command.

Your code should have at least four comments that explain the purpose of a function, variable or command statement . Programming convetion dictatest that all of your procedures should be together (at the top of the program file) and your procedure calls should be together at the bottom of the file.

There is no starter code or txt file for this - you are starting from a blank page in a visualizer.

When you are finished - upload your .txt file to the assignment in schoology.

You Code Assignment 1.1

1.1 Making HMTL Tags

Functions can accept more than one paramenter. For example

#create function to
def zooSpottings(color, animal):
    print("I saw a: " + color +" " + animal + "!")
    
zooSpottings("white", "frog")

However - the order the strings are entered matters. We must follow the pattern or order created in the definition of the function

Anatomy of a Function

What do I do?

In the following examples - the WORD is in blue for clarity - you cannot change the text output color in Python..sorry

Download the .txt file with the starter code - copy and paste that into the IDE - then using the examples, build and test your procedure.

Finally - have the following calls

make_tags("b"," ")
make_stages("p", "Room 112 Is the Best!")
make_stages("h3", "++++++++++++++")

Turn it in according to instructions

98B
1.1MakingHTMLTags.StarterCode.txt
1.1 MakingHTMLTags.StarterCode

Input Defaults to a ____

So if we ask a user to enter a number - the comptuer store that value as a STRING - and we cannot do math with Strings.

So how can we tell the computer that we want the value to be an integer?

number = input("Enter a Number Greater than 0: ")
print(number + number)

number = int(number)
print(number = number)

Basic Operator Pracitce

41KB
NSF_IEC_Python_Programming.2.pdf
pdf
Basic Operator Practice

Variable Naming Conventions

Variable Basics

Python KeyWords that cannot be used as variable names

We use camelCasing for variable names with more than one word

Basic Calculator

The sum of these numbers is: 

The difference betwen 4 and 1 is 3

Multiplication: 3 * 5 = 15

Basic Operators

Final Unit 1 Assignment

Resturant Bill Calculator

Data Types

integers - whole numbers (positive and negative)

floats - numbers with decimals

type - returns the data type of a variable

x = 1
y = 35656222554887711
z = -3255522

print(type(x))
print(type(y))
print(type(z))

print()

Each print() command does two things: displays a value to the user AND moves the cursor down to the next line

However - we can modifiy the end of our print command

print(23)
print(33, end = "-")
print(43)

Explain the output that you can see.

So what does , end = do??

So far we have been joining strings using the +, but for a print statement we can display more than one piece of data without having to join.

print("Alicia")
print("Alicia", 9, end ="!  ")
word = "frogs"
print ("Alicia", 9, word, end ="!")

Consider this output from the visualizer

We are no longing combining strings to create a new string - we are displaying different data types and commands to the user by connecting pieces with a ,

Unit 1 Assessment

Verse by Verse

One area where AI and machine learning are making strides is in the study of semantics, word choice, and language.

Visit this website and create at least a 6 line poem (any type and any muse)

Follow directions for submission

Step: Math

Use your math coding skills to guess the users age

Notice this is nicely psuedocoded out for you - and there are awesome examples of HOW to comment - go crazy and follow the directions.

Step: Feelings

One component of AI is the attempt to replicate human emotion. So we want to include emotions in the conversation - but your chatbot does not have the ability to make a learned response based on the users input so you have to be generic.

feeling = input("How are you feeling today?")
print("Why are you feeling", feeling, " now?")

#now continue this conversation that will work with 
#all the feelings 

Chatbot

Your first major project will be a chatbot - you will simulate a converstation with a user by collecting information and building responses. Because this is a Unit 1 assignment there will not be any error checking - we will assume the user enters the correct information when prompted.

In codingrooms - open the assignment and make sure you are working on the chatBot.py file!

This is JUST A Sample

Step: Two Topics

Pick two topics and continue your conversation. Below is a sample conversation about animals - you may NOT use animals as one of your topics - but I wanted to give you an example

Step: Introduction

Below is an example - but you can create your own. Be sure to #comment the introductionary section. Should your chatbot have a name or a personality?

This is Eliza - the very first chatbot

While this is just an example - it does have a plan psuedocoded for you. Make sure to do comments to identify this section

Go crazy and add some oneline ascii art to your chatbot or use ++,==,--, or other symbols to drawn lines on the screen to seperate different parts of your user experience.

Poetry or Song Lyric Generator

Your Assignment: create a poetry generator that uses personification. Start by seeing if you can create one or two sentences using a "fill in the blank" model and then see if you can evolve it into a four line poem or story.

Follow instructions for submitting

Consider this Simple / Example with Psuedocode

Step Goodbye:

Create a custom goodbye that

Example

Python 3 Turtle Color Names

Turtle Colors

Collecting Data From the User

Typically, we we ask the user to enter data - we will store that value in a variable

name = input("What is your name: ")

Notice that the user can see the question and their response on the console AND that the value stored in name defaults to a string

Scoring

Major Assessment

247KB
Scoring Rubric1.pdf
pdf
Scoring Rubric with Scale

Extensions

Right now - our chatbot doesn't have any options on what to respond. But - could you had some pauses, or some other output phrases that indicate "thinking"

Can you insert a knock knock joke?

Can you make your chatbot overly friendly? rude? nosy?

Python 3 Turtle Cheat Sheet

30KB
nataliemoore_python-turtle-module-cheatsheet.pdf
pdf
Coding Cheat Sheet
http://appjar.info/cheatSheets/Turtle%20T3%20CheatSheet.pdf

Unit 2 Standards

Loops

Meet a drawing turtle

Why is it called a turtle?

The turtle robot, a simple robot controlled from the user's workstation that is designed to carry out the drawing functions assigned to it using a small retractable pen set into or attached to the robot's body

A drawing turtle is going to have three attributes a location, an orientation (or direction), and a pen. The pen will have its own attributes: color, width, and on/off state.

When we program with a turtle, we are using body syntonic reasoning - in other words - we can predict and reason about the turtles movements by imagining what we would do if we were the turtle.

#creating a new drawing turtle named mock
mock = turtle.Turtle()
#moving mock forward 100 steps
mock.forward(100)
#mock is making a left hand turn at 60 degrees
mock.left(60)
This is my real code and the console output

This is sequential code! One line executes AFTER the one before it has finished.

The # are programmer comments that clarify the action

mock.forward()

Mock is the name of the object we created (mock is an instance of the turtle) and we are calling the method/function/procedure of forward. These methods already exist in the Python library.

mock.forward(100)

The 100 is the value passed into the method as an argument. - allowing us to use this method for any number of steps we want the turtle to take.

Writing Algorithims

Learning the functions and syntax in text based language is NOT the hard part. Writing efficient algorithims to solve a problem is the hard part because it requires abstract thinking about both the problem and the possible solution.

Before we start programming, either creatively or to solve a problem, we should plan or visualize our program code. We can use this plan to develop specific instructions for the computer

We can use flowcharts or psuedoce in planning - in this class we will focus more on psuedocode. However, visual thinkers should feel free to use flowcharts if they produce better investigative thinking or program design. Programming styles are individual!

2.0 Writing Your Initials

Have the Turtle Write Your 3 Initials. If you have more than 3 - you may overachieve or drop one. If you have less than 3 you may add your favorite letter!

Because we all have different screen sizes - if you don't think your grid is lining up the way you like - you can check your own screen size

turtle.screensize()

Want to play around with colors? Check out the cheat sheet~

Spaced Psuedocode

While psuedocode is an informal language - we need some basic structure to make it easier to read, easier to use, and easier to share with a fellow programmer

For this class - we will use spacing / indentation as a baseline for organizination

Example:

Images and details adapted from:

Write the Psuedocode for calculating the sum of 10
numbers entered by the user and then displaying the
outcome on the screen

Draw the Letter X?

1.2 Understand the software development life-cycle.

Here are the four basic turtle movements - you should reconzige them as the AP CSP Robot Grid Movemements

What is the deal with the options? Python was built as a learning or teaching language. That means they built in some flexability when it comes to syntax.

Your assignment - turn in a scan of your notes from today with the psuedocode of how to draw the letter x using only these 4 commands and your brain

Flower/Geometric Bot

Program Requirements

  • Programming the turtle u move forwards and/or backwards and turn different angles;

  • Changing the pen colour, fill colour, background colour, and/or pen size;

  • Using loops to avoid unnecessary repetition of code;

  • Using variables to store and reuse information;

  • Descriptive or clarifying comments

  • At least three different outputs/flowers

#background color
y = turtle.Turtle()

screen=y.getscreen()

screen.bgcolor("orange")

#the turtle named Y is getting access to the screen 

Program Expansions

  • Performing mathematical calculations with code;

  • Using Nested Loops

  • Using more than one turtle

Python 3 Turtle Cheat Sheet
Python 3 Turtle Color Names

Basic Turtle Functions

We control the turtle by giving it instructions. Before we go on - review these basic turtle functions()

Forgot how to make a new turtle?

Want to change the turtle's shape?

#the name of my turtle is shelley

shelley.shape('turtle')

To print the current location (x,y coordinates) of your turtle

print(shelley.xcor(),shelley.ycor())

List of Colors in Geometric Art

Drawing Practice

Draw this Shape: Square Logo

Draw This Shape: Overlapping Squares

Python Tutor code visualizer: Visualize code in Python, JavaScript, C, C++, and Java
Logo
https://drive.google.com/file/d/1lQp0zeKDjsRiC0E8w3LdLHwrVNAKzPJH/view?usp=sharingdrive.google.com
AI for Oceans #2 - Code.org
Logo
https://docs.google.com/document/d/1L0qh_qncM26YFBGbqFircIREjeiO-LWrPJx_vqc0Tak/edit?usp=sharingdocs.google.com
Verse by Verse
Python Tutor - Visualize Python, Java, JavaScript, C, C++, Ruby code execution
Logo
Logo
1 Line Art | ASCII art in one line
Python Tutor code visualizer: Visualize code in Python, JavaScript, C, C++, and Java
Logo
Logo