CS177 Fall13 - Lab for week: 3
Lab Title: Using functions
Lab created by: Josh Fuerst
Outcomes
In this lab you will learn:
to define a function, and its input arguments, to accomplish a given task,
how to launch a function from the Python Shell, passing
CS177 Fall 2013 Midterm2 VERSION 02
November 6, 2013
/*
* Last name, First name:
* Your Purdue mail account:
* Your recitation section:
* Signature:
Midterm 1 consists of 25 True/False and multiple choice questions. For each question you are
asked to sele
CS177 Python Programming
Chapter 10
Defining Classes
Adapted from John Zelles
Book Slides
1
Objectives
To appreciate how defining new classes
can provide structure for a complex
program.
To be able to read and write Python class
definitions.
To underst
Announcements
Project 2
Is now posted
Will be due on Oct. 1
Week 7
Midterm on Wed. Oct. 3 in EE 129
Come early, EE is a complicated building
Review session on Oct. 2
Text book part 2 out at Amazon
Lists Reviewed
Syntax:
[ <elt 0>, <elt 1>, , <elt
CS177 Fall12 - Lab for week: 9
Lab Title: Matrices and Images
Lab created by: Nadya Ortiz
Outcomes
In this lab you will practice the concept of matrices and you will work with images. More
specifically, you will transform images using loops and Python Lib
import math # DO NOT MODIFY THIS STATEMENT!
# TODO 1
# Write the function ascii_output
# This function should present the input data in an easy to understand manner
# Something like this:
#Angles:
#
A: X degrees
#
B: X degrees
#
C: X degrees
#Sides:
#
a:
CS177 Fall12 - Lab for week: 11
Lab Title: Recursion
Lab created by: Weihang Wang
Outcomes
In this lab you will practice the concept of recursive functions. More specifically, you will use
recursion to solve problems and work with trees.
The lab assignmen
CS 17700
Loops and Lists
Week 5
1
Announcements
Register the iClicker on Blackboard
Project 2 will be due 11:59pm Oct 1st
Midterm will be on Wed Oct 3rd 8:00pm - 9:30pm in
EE129
Textbook part2 is available at Amazon
2
ANY QUESTIONS?
3
Table of Content
CS177 Fall12 - Lab for week: 7
Lab Title: Lists, Strings and Slicing
Lab created by: Nadya Ortiz
Outcomes
In this lab you will review the concept of List, how to create them, how to access them and foor
loops to scan a list containing another list.
The la
CS177 Fall12 - Lab for week: 6
Lab Title: Lists, Strings and Plotting
Lab created by: Ruby Tahboub
Outcomes
In this lab you will learn how to make use of Lists, Strings and 2D Plotting libraries: numpy
The lab assignment is organized into two parts:
In th
CS 177
Matrices
Week 9
1
Announcements
Project 4: First Team Project
Homework: Pick a team or let us know you need a team
Instructions are on the course pages under projects
Teams should be of size 3
Mid-semester evaluations are now open
Course home
Announcements
Project 5 is due Dec. 6.
Second part is essay questions for CoS teaming
requirements.
The first part you do as a team
The CoS essay gets individually answered and has
separate submission instructions on the home page
Final on Dec 11 in
#Exercise 2
import numpy
import pylab
import math
#TODO 1
def SumOfEvens(myList):
total = 0
i=0
l=len(myList)
while (i<l):
if i%2=0:
total += i
i=i+1
print(total)
#TODO 2
def SubSequence(string1):
i = len(string1)
if i < 8:
print("The length of the input
CS 177
File I/O and Trees
Week 10
1
Announcements
Midterm and Solutions
http:/courses.cs.purdue.edu/_media/cs17700:f12-177midterm1-rel-correct.pdf
http:/courses.cs.purdue.edu/_media/cs17700:f12-177exam1-keys.pdf
2
ANY QUESTIONS?
3
Table of Contents
Fil
The urllib Library
The urllib module provides functionality for getting
information from a URL into python (or save it as a file)
http:/docs.python.org/py3k/library/urllib.request.html#moduleurllib.request
urllib.request.urlopen(url) : opens the provid
import numpy
import pylab
#Plotting Function:
#yList = rabbit list
#zList = fox list
#n = Number of runs
def drawCurve(yList,zList,n):
x = pylab.arange(n)
pylab.title("Foxes and Rabbits")
pylab.ylabel("Number of predator (Foxes)")
pylab.xlabel("\nNumber o
Project 1: The angry birds lost
project due date: Saturday Sept 15th 11:58PM
this is an individual project
Setup
You must create a folder project1 under the CS177 folder you created in lab1.
You can do that using any Windows machine in B160 or G066 labora
Announcements
Project 4 due Wed., Nov 7
Project 5 coming soon; also a team project
This will include the brief essay question for the team
course of Science
New course CS 290 00, Spring 2013
Contemporary Issues in a Digital World
Instructor: Robb Cutl
#Project 2
import numpy
import pylab
#Plotting Function:
#yList = rabbit list
#zList = fox list
#n = Number of runs
def drawCurve(yList,zList,n):
x = pylab.arange(n)
pylab.title("Foxes and Rabbits")
pylab.ylabel("Number of predator (Foxes)")
pylab.xlabel(
CS 17700
Programming with
Multimedia Objects
Week 2
1
Announcements
Attendance: will be taken in every recitation.
iClickers: next week the use of iClickers will be
graded.
Project 1: will be assigned end of next week.
2
Things to do:
1. College Scienc
Announcements
Remember to do the survey; link on home page!
Do it today
Project 1 to be assigned end of next week
Details discussed in recitation next week
Class / Recitation slides available on the syllabus page
Check morning of for latest version
CS177 Fall12 - Lab for week: 3
Lab Title: Using functions
Lab created by: Josh Fuerst
Outcomes
In this lab you will learn:
to define a function, and its input arguments, to accomplish a given task,
how to launch a function from the Python Shell, passing
Announcements
Project 2 due next Monday
Next Tuesday is review session;
Midterm 1 on Wed., EE 129, 8:00 9:30pm
Project 3 to be posted Oct. 3 (next Wed)
Preparing for the Midterm:
Review Chapters 3-6 of Part 1 and chapters 8-9 of Part 2 of the
textbo
CS 177
Review
Week 7
1
Announcements
2
ANY QUESTIONS?
3
Table of Contents
Binary
Assignment statements
Numeric Data Types
Strings
Lists
Functions
Conditionals
Loops
4
Binary
What is the decimal equivalent of (10010)2 ?
What is the largest decima
Announcements
Project 5 is on the street. Second part is essay
questions for CoS teaming requirements.
The first part you do as a team
The CoS essay gets individually answered and has
separate submission instructions
No office hours tomorrow
Recursion
CS177 Fall12 - Lab for week: 10
Lab Title: File Input/Out and Tree Encoding
Lab created by: Rachna Goyal
Outcomes
In this lab you will practice the concept of file input/output and you will work with trees. More
specifically, you will transform a matrix i
CS177 Fall 2012
Lab02: Simple algorithms and Python types
Outcomes
practicing Python types
python variables and assignment statement
getting input from the user (input function)
use the print function
use a library function
Prerequisites
textbook (e-book)
#
#
#
#
The great commond divisor of two numbers m and n is equal to:
if m or n is equal to 1, then the result is 1
if m is equal to 0, then return n; if n is 0, then return m
in other cases, then gcd(m,n)=gcd(n,m0)
def gcd(m,n):
if m=1 or n=1:
return 1
i