cs 105 summer wednesday 3 what to talk about today
play

CS 105 SUMMER WEDNESDAY 3 What to talk about today? From the - PowerPoint PPT Presentation

CS 105 SUMMER WEDNESDAY 3 What to talk about today? From the muddiest points String Formatting... (Including directly looking at the 'X in line' variant) Return vs print When do we use lists? Dictionaries? Boolean


  1. CS 105 SUMMER – WEDNESDAY 3

  2. What to talk about today?  From the muddiest points  String Formatting... (Including directly looking at the 'X in line' variant)  Return vs print  When do we use lists? Dictionaries?  Boolean expressions I want to touch on  The use of the 'in' operator  The use of short circuiting  Challenge questions you want me to hit? Homework you want me to hit?

  3. Some things not to worry about  Do you need to memorize binary and hex?  No – although binary is super easy with a bit of practice!  Hypothesis testing  Useful, but largely in the reading for interest/relation to functions  "What excel do I need to know?" – When you need it, the reading topic will include it  We get as far as V/HLookUp as far as task complexity, probably second half of next week onward  Tuples and sets – largely deemphasizing them  Although sets do have a use – let's check unique elements of a list!

  4. Quiz 2 comments https://kpwritesb  High level stats: log.files.wordpre ss.com/2017/10  Mean 82%, Median 87% /fireworks-  Pretty good animation-33- 2.gif?w=300&h =294&crop=1  Office hours, office hours  Practice – there is some redundancy! ( Do all the homework )  Better content curve  Quiz 3's programming will focus on conditionals (this week's reading), some expressions  Quiz 4 may dip back into string formatting – but the practice will reflect this!

  5. String Formatting  Let's take a look at HW 4.15 and 4.34  Then let's also try  A string with an integer and a floating point  Looking at the Python string formatting docs  https://docs.python.org/3/library/string.htm l#formatspec

  6. Return vs Print (also function calls)  Return is used to return a value to a place  You touched on modularization in lab yesterday (although lab was a bit large…)  Print just prints output to console  Let's consider – function which calculates price used to calculate a shopping list

  7. List and dictionary usage  You can use lists whenever you want a non-unique stack of "stuff"  In practice, data type tends to be the same, although it does not HAVE to be  This is how Java lists differ from, say, ArrayLists in Java  Dictionary usage is a bit more clear  I have a key for a value  I have a name for an address  I have a user_name for a list of data  I have a company name for a company object (departments, employees, etc.)

  8. What about sets and tuples?  Sets enforce uniqueness, but…  So can lists with in – let's see an example  Tuples I personally only ever use in reference to the data analysis module pandas  I've never used named tuples - they're like mini objects  from collections import namedtuple  Person = namedtuple('Person', 'first_name last_name zip_code')  p1 = Person('Joe', 'Schmoe', '93002')

  9. Boolean Expressions – the use of in  The in operator is used to check for membership in a collection  I'd like to check…  If a string contains 'hello'  If the list ['h', 'ello'] contains 'hello'  if the list, ['hello world', 'I need coffee'] contains 'hello'

  10. Short Circuit  Think about this prompt: "If a number is even and positive, return the number multiplied by 2."  If the number is odd , do you need to check if it is positive?

  11. Short circuit – a more salient example  "If the parameter is a number and it is even, return its square root"  vs  "If something is even and a number, return its square root"

  12. That was my planned content  If there are no questions, we will at least go over…  5.23  5.34  5.37

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend