Compsci 101.2, Fall 2015 9.1 #TBT l Finish some Python concepts and questions from earlier  Review for midterm exam l Strategies for success in 101 assignments.

Slides:



Advertisements
Similar presentations
CATHERINE AND ANNIE Python: Part 3. Intro to Loops Do you remember in Alice when you could use a loop to make a character perform an action multiple times?
Advertisements

CompSci 101 Introduction to Computer Science February 3, 2015 Prof. Rodger Lecture given by Elizabeth Dowd.
Introduction to Computing Science and Programming I
String and Lists Dr. Benito Mendoza. 2 Outline What is a string String operations Traversing strings String slices What is a list Traversing a list List.
 Caesar used to encrypt his messages using a very simple algorithm, which could be easily decrypted if you know the key.  He would take each letter.
Programming with Alice Computing Institute for K-12 Teachers Summer 2011 Workshop.
Python Magic Select a Lesson: Why Learn to Code? Basic Python Syntax
Lists Introduction to Computing Science and Programming I.
Python November 18, Unit 7. So Far We can get user input We can create variables We can convert values from one type to another using functions We can.
Programming – Touch Sensors Intro to Robotics. The Limit Switch When designing robotic arms there is always the chance the arm will move too far up or.
Guide to Programming with Python
Cryptography Programming Lab
An Introduction to Textual Programming
by Chris Brown under Prof. Susan Rodger Duke University June 2012
1 Lab Session-III CSIT-120 Fall 2000 Revising Previous session Data input and output While loop Exercise Limits and Bounds Session III-B (starts on slide.
General Programming Introduction to Computing Science and Programming I.
Instructor: Chris Trenkov Hands-on Course Python for Absolute Beginners (Spring 2015) Class #002 (January 17, 2015)
STRINGS CMSC 201 – Lab 3. Overview Objectives for today's lab:  Obtain experience using strings in Python, including looping over characters in strings.
Compsci 101.2, Fall PFTT (plan for this Thursday) l What is a Python program?  In the context of what we do in Compsci 101  In a neuroscience.
Nonvisual Arrays and Recursion by Chris Brown under Prof. Susan Rodger Duke University June 2012.
By the end of this session you should be able to...
Compsci 101.2, Fall PFThursday l Review Organization and Problem-Solving  Defining functions, calling functions  Return types, print, None l.
Collecting Things Together - Lists 1. We’ve seen that Python can store things in memory and retrieve, using names. Sometime we want to store a bunch of.
Working on exercises (a few notes first). Comments Sometimes you want to make a comment in the Python code, to remind you what’s going on. Python ignores.
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.
Functions. Built-in functions You’ve used several functions already >>> len("ATGGTCA")‏ 7 >>> abs(-6)‏ 6 >>> float("3.1415")‏ >>>
Compsci 6/101, Spring More on Python, Tools, Compsci 101 l APTs, Assignments, Tools  APT: Algorithmic Problem-solving and Testing  How to get.
Compsci 101.2, Fall PFTheWeek 9/21-9/25 l Potpourri, Hodgepodge of Review Concepts  File reading and writing  Boolean expressions  Arithmetic.
Functions CSE 1310 – Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1.
VARIABLES Programmes work by manipulating data placed in memory. The data can be numbers, text, objects, pointers to other memory areas, and more besides.
1 CS161 Introduction to Computer Science Topic #9.
My Python Programmes NAME:.
Perl Tutorial. Why PERL ??? Practical extraction and report language Similar to shell script but lot easier and more powerful Easy availablity All details.
Strings Mr. Smith AP Computer Science A. What are Strings? Name some of the characteristics of strings: A string is a sequence of characters, such as.
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 CS161 Introduction to Computer Science Topic #8.
Compsci 101.2, Fall Plan for October l Review Catchup and Midterm and Future  Make sure everyone understand options l Review Assignment.
CompSci Review of Recursion with Big-Oh  Recursion is an indispensable tool in a programmer’s toolkit  Allows many complex problems to be solved.
Compsci 101.2, Fall Plan for TDAFB (after fall break) l Hear via about plans to catch-up and stay-ahead  Profs. Rodger and Astrachan to.
Compsci 101.2, Fall Plan for FWON l Review current assignments and APTs  Review Dictionaries and how to use them  Code and APT walk-through.
Compsci 101.2, Fall Plan for October 29 l Review dictionaries and their use  Very efficient, easy to use  Efficiency doesn't matter much for.
1 Program Development  The creation of software involves four basic activities: establishing the requirements creating a design implementing the code.
Compsci 101.2, Fall Plan for October 22 l Images, tuples, RGB color model  Image processing by understanding API  Image processing with tuples.
Week 14 - Monday.  What did we talk about last time?  Heaps  Priority queues  Heapsort.
Variables and Strings. Variables  When we are writing programs, we will frequently have to remember a value for later use  We will want to give this.
Compsci 101.2, Fall Plan for eleven-four l Thinking about APTs and test problems  How do you choose: list, string, set, dictionary  Experience?
Compsci 06/101, Spring Compsci 6: PFTW l Problem solving and (Python) programming  What are the steps in solving an APT?  How do you get better.
12. MODULES Rocky K. C. Chang November 6, 2015 (Based on from Charles Dierbach. Introduction to Computer Science Using Python and William F. Punch and.
CompSci 101 Introduction to Computer Science February 11, 2016 Prof. Rodger.
Functions CSE 1310 – Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1.
Introduction to Arrays. Learning Objectives By the end of this lecture, you should be able to: – Understand what an array is – Know how to create an array.
Lecture 14 – lists, for in loops to iterate through the elements of a list COMPSCI 1 1 Principles of Programming.
CMSC 104, Section 301, Fall Lecture 18, 11/11/02 Functions, Part 1 of 3 Topics Using Predefined Functions Programmer-Defined Functions Using Input.
CompSci 4 Java 4 Apr 14, 2009 Prof. Susan Rodger.
CompSci 101 Introduction to Computer Science March 8, 2016 Prof. Rodger.
Part 1 Learning Objectives To understand that variables are a temporary named location to store data and that programmers work with different data types.
CompSci 101 Introduction to Computer Science February 5, 2015 Prof. Rodger Lecture given by Elizabeth Dowd compsci101 spring151.
CompSci 101 Introduction to Computer Science
Introduction to Python
CompSci 101 Introduction to Computer Science
CompSci 101 Introduction to Computer Science
CompSci 101 Introduction to Computer Science
CompSci 101 Introduction to Computer Science
File Handling Programming Guides.
CMSC201 Computer Science I for Majors Lecture 19 – Recursion
Encryption and Decryption
Fundamentals of Data Representation
String and Lists Dr. José M. Reyes Álamo.
Remembering lists of values lists
CSE 303 Concepts and Tools for Software Development
Presentation transcript:

Compsci 101.2, Fall #TBT l Finish some Python concepts and questions from earlier  Review for midterm exam l Strategies for success in 101 assignments  Reading, writing, understanding, … success!  Knowing when to ask for help when you’re feeling …

Compsci 101.2, Fall Counting Questions

Compsci 101.2, Fall Extreme Python, Extreme Values l If I start reading a list of numbers …..  How do you remember the largest?  What do you think or do when I say “572” … l Keep a variable storing extreme/max/min  Update when new/next value processed  What do you initialize max/min to?  What if you want the index as well as the value?

Compsci 101.2, Fall Find largest value in a list of … Max value: [1,2,3],["zebra", "armadillo"]  Does code below work for strings? maxval = 0 for val in lst: # type of data if val > maxavl: # initial maxval? maxval = val return maxval What about using max(lst), similar to sum(lst)

Compsci 101.2, Fall Find largest value in a list of … grades: ["owen:3.8", "bob:3.7", "susan:3.9"] mname = "" mgpa = 0.0 for data in grades: # type of data parts = data.split(':') # type of parts name = parts[0] gpa = float(parts[1]) # type of gpa if gpa > mgpa: # initial mgpa? mgpa = gpa mname = name return mname

Compsci 101.2, Fall How to approach a 101 Assignment l Programming compared to Cooking  Follow a recipe to create {food or masterpiece}?  Understand the whole project before coding  Know at least a few steps before coding

Compsci 101.2, Fall What do we learn from assignment? l We will snarf to get started  We will modify Pigify.py  We will create Caesar.py l The grading tells us:  Caesar counts the same as Pigify  The chi-squared test will be difficult  The README will be worth more than normal

Compsci 101.2, Fall What does HowTo say about Pigify.py l Lots of details on how to pigify a word  Ignore at first, make the structure of the program work l We have to write four functions  Details on function headers/prototypes given  Details on function functionality given l Types and values in main program  Work to understand the flow  Run the program, where do you start?

Compsci 101.2, Fall Making pigall work l Make sure you understand this  What do you need to do so this works?  What is header, signature, prototype: pigword def pigall(st): all = [] for word in st.split(): all.append(pigword(word)) return ' '.join(all)

Compsci 101.2, Fall Making pigword work l Once you know what pigword does, how do you implement it?  Review rules for piglatin  Review code for APT you hopefully did l Don’t try to make every case work at once!  Start small and grow a working program.  How about first word is a vowel to begin …  Then add another case, …

Compsci 101.2, Fall If pigword is done … else … Get to unpigall and unpigword  Which will be easy? Why?  Can you do one easy case in unpigword ? l Why does it help to do one case at a time?  Builds confidence in reaching completion  Decreases time-to-completion: code works! Bugs easier to find.

Compsci 101.2, Fall In class Questions

Compsci 101.2, Fall Cracking the Caesar Cipher l First create Caesar.py  Where do you start?  What’s in the main program?  What’s copied from Pigify.py l What functions will you write first?  Where do you find this information?  What’s not clear about it?

Compsci 101.2, Fall Lots of details in making this work l How do you loop over characters in word?  Is there anything familiar here? l How do you know if a character is  Alphabetic?  Uppercase or lowercase?  A vowel or a consonant? l Once again: start simple, make something work, add functionality incrementally

Compsci 101.2, Fall How do you know encryption works? l Is this a chicken and egg question?  Could you write decrypt first?  Isn’t decrypting by eyeball decryption just encrypting 26 times? 14 Pljbqfjbp fq'p bxpv ql zlrkq colj 1-10, yrq klq xitxvp 15 Qmkcrgkcq gr'q cyqw rm amslr dpmk 1-10, zsr lmr yjuywq 16 Rnldshldr hs'r dzrx sn bntms eqnl 1-10, ats mns zkvzxr 17 Sometimes it's easy to count from 1-10, but not always 18 Tpnfujnft ju't fbtz up dpvou gspn 1-10, cvu opu bmxbzt 19 Uqogvkogu kv'u gcua vq eqwpv htqo 1-10, dwv pqv cnycau

Compsci 101.2, Fall Can you call a function 26 times? l Encrypt using 26 shift keys and … eyeball! em = #encrypted message for n in range(26): sem = encrypt(em,n) print n,sem

Compsci 101.2, Fall What is chi-square about? l If you expect [5, 9, 6, 11] then how close is?  [1, 9, 4, 8]  [4, 8, 9, 4]  [5, 5, 5, 5] What does  (C i -E i ) 2 /E i mean?  4 2 / / / /11 =  1 2 / / / /11 =  0 2 / / / /11 = l And the answer is …