×

### Let's log you in.

or

Don't have a StudySoup account? Create one here!

×

or

by: Eunice

23

0

4

# Week 3 Notes CS 1110-002

Eunice
Cornell

Get a free preview of these Notes, just enter your email below.

×
Unlock Preview

Week 3!
COURSE
Intro to Computing using Python
PROF.
Lee, Van Loan
TYPE
Class Notes
PAGES
4
WORDS
CONCEPTS
CS, Python
KARMA
25 ?

## Popular in ComputerScienence

This 4 page Class Notes was uploaded by Eunice on Saturday February 13, 2016. The Class Notes belongs to CS 1110-002 at Cornell University taught by Lee, Van Loan in Spring 2016. Since its upload, it has received 23 views. For similar materials see Intro to Computing using Python in ComputerScienence at Cornell University.

×

## Reviews for Week 3 Notes

×

×

### What is Karma?

#### You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!

Date Created: 02/13/16
CS 1110 Spring 2016 Lee and Van Loan February 9, 2016  3.  logical/Boolean operations o a Boolean expression can be stored in a variable (the result of the expression will be stored) x y x AND y true true true true false false false true false false false false x y x OR y true true true true false true false true true false false false  and: both statements must be true for the overall statement to be true o a<=x and x<=b o is the same as o a<=x<=b  or: at least one of the statements must be true for the overall statement to be true  not: o not true = false o not false = true  4. o function  implement a function: package a computational idea so that others can use it  m = fct(x,y)  fct: name given to a function  x, y: both are arguments o arguments may be expressions  python functions: max, min, abs, round o modules  common: math, string, random, numpy, scipy, timeit, urllib2, PIL (image processing), datetime  to get help:  >>> help (‘whatever I need help on’)  to access math module  >>> import math  >>> print math.sqrt(4)  2  this is dot notation o advantage being that if you are using multiple modules that each have functions with the same name, then dot notation clarifies  to access a function in the math module  >>> from math import sqrt  >>> print sqrt(4)  2  >>> from math import sqrt, pi, cos, log  [just give me what I need]  >>> from math import *  * imports all functions  functions: math.floor, math.ceil, math.round o building functions  >>> def function(argument): [header]  >>> body statement  >>> more body statements  >>> return a variable February 11, 2016  modules and functions o you can use a function without understanding how the function works o authors of a function must make available the how-to-use information through docstrings and comments o rule 1 and 2  module starts with authorship comments and an explanation  #module name  #author(s) names (and netid)  #last modified date  “””a doctstring: a module to ____””” o rule 3.  each function starts with a docstring “specification”  short summary that states what the function returns (post condition)  longer prose can be include which gives more useful info  precondition: conditions that the argument must satisfy if the function is to work o know how to  access functions: import  create functions: def  document functions: docstrings and comments  procedures o procedures are functions that do not return values, they “do something”  functions can call other functions o iterations, nesting, loops, random computations, recursion (will learn)  simple graphics: o makewindow  first: get a canvass  from simplegraphics import*  n=5  makewindow(n)  window now exists: -5<=x<=5 and -5<=y<=5  makewindow (n, bgcolor=PURPLE) o this is an optional argument o overrides the default of white  makewindow (n, bgcolor=ORANGE, labels=False) o disables axes’ labels o another optional argument o optional arguments don’t require a certain order, they’re like synonyms o module has data, 13 different colors o showwindow o drawrect  must tell the program:  the center of rectangle  horizontal dimension  vertical  optional  fill color o default is no color  width of perimeter  color of perimeter highlight  rotation angle (theta=degree)  x=0;y=0;L=5;W=3  Drawerct(x,y,L,W,fillcolor=magenta, edgewidth=6,theta=30)  showwindow() o drawdisk  must tell  center  radius  in order to get the row of diminishing circles (use iterations of a math function) o drawstar  also needs a center and radius o drawlineseg  need to define the start and end points  can define the color and width o drawtext  tell:  the location of text  the string  can tell: the color and size o drawTile  tell the center, the radius, three colors of 3 objects in the tile (x,y,r,c1,c2,c3)  color  set of three number between 0 and 1, number represent the amount of  [red, green, blue] a list of length three  an application script uses procedures and functions defined above

×

×

### BOOM! Enjoy Your Free Notes!

×

Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'

## Why people love StudySoup

Bentley McCaw University of Florida

#### "I was shooting for a perfect 4.0 GPA this semester. Having StudySoup as a study aid was critical to helping me achieve my goal...and I nailed it!"

Anthony Lee UC Santa Barbara

#### "I bought an awesome study guide, which helped me get an A in my Math 34B class this quarter!"

Steve Martinelli UC Los Angeles

#### "There's no way I would have passed my Organic Chemistry class this semester without the notes and study guides I got from StudySoup."

Parker Thompson 500 Startups

#### "It's a great way for students to improve their educational experience and it seemed like a product that everybody wants, so all the people participating are winning."

Become an Elite Notetaker and start selling your notes online!
×

### Refund Policy

#### STUDYSOUP CANCELLATION POLICY

All subscriptions to StudySoup are paid in full at the time of subscribing. To change your credit card information or to cancel your subscription, go to "Edit Settings". All credit card information will be available there. If you should decide to cancel your subscription, it will continue to be valid until the next payment period, as all payments for the current period were made in advance. For special circumstances, please email support@studysoup.com

#### STUDYSOUP REFUND POLICY

StudySoup has more than 1 million course-specific study resources to help students study smarter. If you’re having trouble finding what you’re looking for, our customer support team can help you find what you need! Feel free to contact them here: support@studysoup.com

Recurring Subscriptions: If you have canceled your recurring subscription on the day of renewal and have not downloaded any documents, you may request a refund by submitting an email to support@studysoup.com