Compsci 6/101, Spring 2012 7.1 Plan for the Week l Understand programming in general in Python  How do we design programs? What is a program?  How do.

Slides:



Advertisements
Similar presentations
This Week More Types boolean string Modules print statement Writing programs if statement Type boolean.
Advertisements

Lecture 04 – Classes.  Python has a number of classes built-in  lists, dictionaries, sets, int, float, boolean, strings  We can define our own classes.
Lecture 12 – ADTs and Stacks.  Modularity  Divide the program into smaller parts  Advantages  Keeps the complexity managable  Isolates errors (parts.
CS 106 Introduction to Computer Science I 11 / 08 / 2006 Instructor: Michael Eckmann.
Chapter 2 Writing Simple Programs
Compilers and Interpreters. Translation to machine language Every high level language needs to be translated to machine code There are different ways.
Main task -write me a program
Starter  Identify the separate tasks to be performed in the programming task below (break it down into numbered sections).  A program is needed to prompt.
CS 106 Introduction to Computer Science I 04 / 07 / 2010 Instructor: Michael Eckmann.
Structure of program You must start with a module import# You must then encapsulate any while loop in a main function at the start of the program Then.
Python quick start guide
Python.
1 Programming James King 12 August Aims Give overview of concepts addressed in Web based programming module Teach you enough Java to write simple.
COMPUTER SCIENCE FEBRUARY 2011 Lists in Python. Introduction to Lists Lists (aka arrays): an ordered set of elements  A compound data type, like strings.
1 CMPT 275 High Level Design Phase Architecture. Janice Regan, Objectives of Design  The design phase takes the results of the requirements analysis.
CIT 590 Intro to Programming Last lecture on Python.
Introduction. 2COMPSCI Computer Science Fundamentals.
This Week The string type Modules print statement Writing programs if statements (time permitting) The boolean type (time permitting)
Object Oriented Design. Object-Oriented Design Method for designing computer programs –Useful for thinking about large problems Consider “objects” interacting.
Unit 1 – Improving Productivity By Joe Burridge. 1.1Why did you use a computer? What other systems / resources could you have used? I used a computer.
Python – Procedures If the same piece of code needs to be used several times we can use a loop - but only if those times are all together. If you need.
Compsci 06/101, Fall Compsci 6/101: Random debugging?!# l The joys and rewards of writing code to solve a problem  How do we know where to begin?
Python Programming Using Variables and input. Objectives We’re learning to build functions and to use inputs and outputs. Outcomes Build a function Use.
Compsci 06/101, Fall What will you do in Compsci 6 Today? l Learn about selection and if/else statements  In context of solving problems  Understanding.
Classes 1 COMPSCI 105 S Principles of Computer Science.
Compsci 6/101, Spring More on Python, Tools, Compsci 101 l APTs, Assignments, Tools  APT: Algorithmic Problem-solving and Testing  How to get.
C463 / B551 Artificial Intelligence Dana Vrajitoru Python.
Python Functions.
The Problems HTTP is disconnected So many database vendors Create a simple consistent versatile interface on the data Look at ADO.NET classes OleDb SQL.
gence.jpg al.php.htm.
Make a dice challenge! This is a starter activity and should take 5 minutes [ slide 1 ] 1.Log in to your computer 2.Open IDLE 3.Copy the code below in.
Introduction to Python Lesson 1 First Program. Learning Outcomes In this lesson the student will: 1.Learn some important facts about PC’s 2.Learn how.
Lecture 10 – Algorithm Analysis.  Next number is sum of previous two numbers  1, 1, 2, 3, 5, 8, 13, 21 …  Mathematical definition 2COMPSCI Computer.
 m C r =m!/r!(m-r)!  Property: m C r = m C (m-r)  Example: ◦ If you have 10 pens, all in different colors, and you want to bring two of them to class,
MA471 Fall 2003 Lecture 2. On With The Games Today we are going to watch each group play a couple of rounds of cards. We will go through the game slowly.
If the same piece of code needs to be used several times we can use a loop – but only if those times are all together. If you need to run the same bit.
1 Programming 2 Aims Give overview of concepts addressed in Web based programming module Teach you enough Java to write simple web and network applications.
Compsci 101.2, Fall Plan for October l Review Catchup and Midterm and Future  Make sure everyone understand options l Review Assignment.
Last Week Modules Save functions to a file, e.g., filename.py The file filename.py is a module We can use the functions in filename.py by importing it.
Author Ivan Dominic Baguio. ABOUT THE GAME Game Objective  The goal of each player in the game is to discard all cards in his hand before every other.
PROGRAMMING IN PYTHON LETS LEARN SOME CODE TOGETHER!
Compsci 101.2, Fall Plan for eleven-four l Thinking about APTs and test problems  How do you choose: list, string, set, dictionary  Experience?
Python Basics  Functions  Loops  Recursion. Built-in functions >>> type (32) >>> int(‘32’) 32  From math >>>import math >>> degrees = 45 >>> radians.
Python Programing: An Introduction to Computer Science
Exceptions Lecture 11 COMP 401, Fall /25/2014.
CompSci 101 Introduction to Computer Science January 26, 2016 Prof. Rodger compsci 101, spring
For Loop GCSE Computer Science – Python. For Loop The for loop iterates over the items in a sequence, which can be a string or a list (we will discuss.
Review: A Structural View program modules -> main program -> functions -> libraries statements -> simple statements -> compound statements expressions.
Getting Started With Python Brendan Routledge
CompSci 101 Introduction to Computer Science February 16, 2016 Prof. Rodger “All your troubles are due to those ‘ifs’,” declared the Wizard. If you were.
CompSci 101 Introduction to Computer Science March 8, 2016 Prof. Rodger.
CompSci 101 Introduction to Computer Science February 5, 2015 Prof. Rodger Lecture given by Elizabeth Dowd compsci101 spring151.
CSC 108H: Introduction to Computer Programming
Chapter 2 Writing Simple Programs
CSC 222: Object-Oriented Programming
Compsci 6/101: I Python Techniques for looping
Functions Review.
CSC 108H: Introduction to Computer Programming
CSC 108H: Introduction to Computer Programming
CompSci 101 Introduction to Computer Science
CompSci 101 Introduction to Computer Science
CSc 110, Spring 2018 Lecture 8: input and Parameters
Python Basics with Jupyter Notebook
Loops and Simple Functions
Introduction to Computer Science
CMPT 120 Machine that can see! Lecture 21 – Unit 4 – Computer Vision
GCSE Computing.
Presentation transcript:

Compsci 6/101, Spring Plan for the Week l Understand programming in general in Python  How do we design programs? What is a program?  How do we design functions?  How do we design modules? l Review lists, loops, functions, understand sets  Motivate with examples that are connected to the world  Sometimes the connection is tenuous  What do you do when you have free time?

Compsci 6/101, Spring How to write a program (in Python) l Understand the big picture of what you're doing  For small programs this is likely manageable  For big programs, the big picture might be very big l What are the use-cases, different granularities  How will a user interact with the program or system?  Small grain-size to larger-grain size User will choose which transform to use User will be able to specify a filename for saving l We will do this informally, often done formally as part of specifying what the program/system does

Compsci 6/101, Spring Getting a program to work l Write small functions, test them  Each function should do one thing  Ideally testable independently of other functions/code l Develop the program incrementally  Write small sections, run them, try them, test them  Make it run, make it right, (make it fast, make it small) l Carefully document function dependencies  What parameters needed? What value(s) returned?  Side effects altering parameters or program state e.g., printing values or saving a file

Compsci 6/101, Spring U.S.C. § 5361–5367 l US Code section 5361 aka UIGEA  Unlawful Internet Gambling Enforcement Act  Passed in 2006, took effect June 1, 2010  What is legal, what is illegal, what are effects?

Compsci 6/101, Spring Statistical Analysis of Poker Hand l How do we represent cards? Deck? Suit? Rank?  What is a card?  What can you do with a card?  How will we represent a hand?  Keep things simple: lists help! l How do we 'create' a deck  Number of cards?  Code for creating cards?  Loop over suits/ranks  Debugging assistance!

Compsci 6/101, Spring Coping with cards: Cardtester.py l Dealing a deck of cards in Python: Cardtester.py  In code below, what is a deck?  What is a card?  What's easier to understand: [0,1] or "ace of hearts"  How do nested loops work?  Why do we use strings? Lists? Tuples? def getDeck(): d = [] for rank in range(0,13): for suit in range(0,4): d.append([rank,suit]) return d

Compsci 6/101, Spring From Lists to Tuples l lists, lints, lines, fines, fixes, fixed l lists, fists, fiats, feats, seats, stats, stars, stark, stack, stuck def get_roll(): return [random.randint(1,6),random.randint(1,6)] def track(n): store = set() for x in range(n): store.add(get_roll()) return len(store ) store.add(get_roll()) TypeError: unhashable type: 'list'

Compsci 6/101, Spring Vince cs.duke.edu Vincent Conitzer will receive the 2011 Computers and Thought Award … The award is presented every two years to the world’s leading AI researchers under the age of 35. Conitzer, an assistant professor of computer science at Duke University, is receiving the award in recognition of his seminal work at the boundary of microeconomic theory and artificial intelligence, in particular for groundbreaking work on computational aspects of game theory, social choice, and mechanism design.