61a lecture 13
play

61A Lecture 13 Wednesday, October 2 Announcements 2 Announcements - PowerPoint PPT Presentation

61A Lecture 13 Wednesday, October 2 Announcements 2 Announcements Homework 3 deadline extended to Wednesday 10/2 @ 11:59pm. 2 Announcements Homework 3 deadline extended to Wednesday 10/2 @ 11:59pm. Optional Hog strategy contest due


  1. Representing Strings: the ASCII Standard American Standard Code for Information Interchange 8 rows: 3 bits 9

  2. Representing Strings: the ASCII Standard American Standard Code for Information Interchange 8 rows: 3 bits 16 columns: 4 bits 9

  3. Representing Strings: the ASCII Standard American Standard Code for Information Interchange 8 rows: 3 bits 16 columns: 4 bits • Layout was chosen to support sorting by character code 9

  4. Representing Strings: the ASCII Standard American Standard Code for Information Interchange 8 rows: 3 bits 16 columns: 4 bits • Layout was chosen to support sorting by character code • Rows indexed 2-5 are a useful 6-bit (64 element) subset 9

  5. Representing Strings: the ASCII Standard American Standard Code for Information Interchange 8 rows: 3 bits 16 columns: 4 bits • Layout was chosen to support sorting by character code • Rows indexed 2-5 are a useful 6-bit (64 element) subset • Control characters were designed for transmission 9

  6. Representing Strings: the ASCII Standard American Standard Code for Information Interchange "Line feed" (\n) 8 rows: 3 bits 16 columns: 4 bits • Layout was chosen to support sorting by character code • Rows indexed 2-5 are a useful 6-bit (64 element) subset • Control characters were designed for transmission 9

  7. Representing Strings: the ASCII Standard American Standard Code for Information Interchange "Bell" (\a) "Line feed" (\n) 8 rows: 3 bits 16 columns: 4 bits • Layout was chosen to support sorting by character code • Rows indexed 2-5 are a useful 6-bit (64 element) subset • Control characters were designed for transmission 9

  8. Representing Strings: the ASCII Standard American Standard Code for Information Interchange "Bell" (\a) "Line feed" (\n) 8 rows: 3 bits 16 columns: 4 bits • Layout was chosen to support sorting by character code • Rows indexed 2-5 are a useful 6-bit (64 element) subset • Control characters were designed for transmission (Demo) 9

  9. Representing Strings: the Unicode Standard 10

  10. Representing Strings: the Unicode Standard http://ian-albert.com/unicode_chart/unichart-chinese.jpg 10

  11. Representing Strings: the Unicode Standard • 109,000 characters http://ian-albert.com/unicode_chart/unichart-chinese.jpg 10

  12. Representing Strings: the Unicode Standard • 109,000 characters • 93 scripts (organized) http://ian-albert.com/unicode_chart/unichart-chinese.jpg 10

  13. Representing Strings: the Unicode Standard • 109,000 characters • 93 scripts (organized) • Enumeration of character properties, such as case http://ian-albert.com/unicode_chart/unichart-chinese.jpg 10

  14. Representing Strings: the Unicode Standard • 109,000 characters • 93 scripts (organized) • Enumeration of character properties, such as case • Supports bidirectional display order http://ian-albert.com/unicode_chart/unichart-chinese.jpg 10

  15. Representing Strings: the Unicode Standard • 109,000 characters • 93 scripts (organized) • Enumeration of character properties, such as case • Supports bidirectional display order • A canonical name for every character http://ian-albert.com/unicode_chart/unichart-chinese.jpg 10

  16. Representing Strings: the Unicode Standard • 109,000 characters • 93 scripts (organized) • Enumeration of character properties, such as case • Supports bidirectional display order • A canonical name for every character http://ian-albert.com/unicode_chart/unichart-chinese.jpg U+0058 LATIN CAPITAL LETTER X 10

  17. Representing Strings: the Unicode Standard • 109,000 characters • 93 scripts (organized) • Enumeration of character properties, such as case • Supports bidirectional display order • A canonical name for every character http://ian-albert.com/unicode_chart/unichart-chinese.jpg U+0058 LATIN CAPITAL LETTER X U+263a WHITE SMILING FACE 10

  18. Representing Strings: the Unicode Standard • 109,000 characters • 93 scripts (organized) • Enumeration of character properties, such as case • Supports bidirectional display order • A canonical name for every character http://ian-albert.com/unicode_chart/unichart-chinese.jpg U+0058 LATIN CAPITAL LETTER X U+263a WHITE SMILING FACE U+2639 WHITE FROWNING FACE 10

  19. Representing Strings: the Unicode Standard • 109,000 characters • 93 scripts (organized) • Enumeration of character properties, such as case • Supports bidirectional display order • A canonical name for every character http://ian-albert.com/unicode_chart/unichart-chinese.jpg U+0058 LATIN CAPITAL LETTER X ' ☺ ' U+263a WHITE SMILING FACE U+2639 WHITE FROWNING FACE 10

  20. Representing Strings: the Unicode Standard • 109,000 characters • 93 scripts (organized) • Enumeration of character properties, such as case • Supports bidirectional display order • A canonical name for every character http://ian-albert.com/unicode_chart/unichart-chinese.jpg U+0058 LATIN CAPITAL LETTER X ' ☺ ' ' ☹ ' U+263a WHITE SMILING FACE U+2639 WHITE FROWNING FACE 10

  21. Representing Strings: the Unicode Standard • 109,000 characters • 93 scripts (organized) • Enumeration of character properties, such as case • Supports bidirectional display order • A canonical name for every character http://ian-albert.com/unicode_chart/unichart-chinese.jpg U+0058 LATIN CAPITAL LETTER X ' ☺ ' ' ☹ ' U+263a WHITE SMILING FACE U+2639 WHITE FROWNING FACE (Demo) 10

  22. Representing Strings: UTF-8 Encoding 11

  23. Representing Strings: UTF-8 Encoding UTF (UCS (Universal Character Set) Transformation Format) 11

  24. Representing Strings: UTF-8 Encoding UTF (UCS (Universal Character Set) Transformation Format) Unicode: Correspondence between characters and integers 11

  25. Representing Strings: UTF-8 Encoding UTF (UCS (Universal Character Set) Transformation Format) Unicode: Correspondence between characters and integers UTF-8: Correspondence between those integers and bytes 11

  26. Representing Strings: UTF-8 Encoding UTF (UCS (Universal Character Set) Transformation Format) Unicode: Correspondence between characters and integers UTF-8: Correspondence between those integers and bytes A byte is 8 bits and can encode any integer 0-255. 11

  27. Representing Strings: UTF-8 Encoding UTF (UCS (Universal Character Set) Transformation Format) Unicode: Correspondence between characters and integers UTF-8: Correspondence between those integers and bytes A byte is 8 bits and can encode any integer 0-255. bytes 11

  28. Representing Strings: UTF-8 Encoding UTF (UCS (Universal Character Set) Transformation Format) Unicode: Correspondence between characters and integers UTF-8: Correspondence between those integers and bytes A byte is 8 bits and can encode any integer 0-255. bytes integers 11

  29. Representing Strings: UTF-8 Encoding UTF (UCS (Universal Character Set) Transformation Format) Unicode: Correspondence between characters and integers UTF-8: Correspondence between those integers and bytes A byte is 8 bits and can encode any integer 0-255. 00000000 0 bytes integers 11

  30. Representing Strings: UTF-8 Encoding UTF (UCS (Universal Character Set) Transformation Format) Unicode: Correspondence between characters and integers UTF-8: Correspondence between those integers and bytes A byte is 8 bits and can encode any integer 0-255. 00000000 0 00000001 1 bytes integers 11

  31. Representing Strings: UTF-8 Encoding UTF (UCS (Universal Character Set) Transformation Format) Unicode: Correspondence between characters and integers UTF-8: Correspondence between those integers and bytes A byte is 8 bits and can encode any integer 0-255. 00000000 0 00000001 1 bytes integers 00000010 2 11

  32. Representing Strings: UTF-8 Encoding UTF (UCS (Universal Character Set) Transformation Format) Unicode: Correspondence between characters and integers UTF-8: Correspondence between those integers and bytes A byte is 8 bits and can encode any integer 0-255. 00000000 0 00000001 1 bytes integers 00000010 2 00000011 3 11

  33. Representing Strings: UTF-8 Encoding UTF (UCS (Universal Character Set) Transformation Format) Unicode: Correspondence between characters and integers UTF-8: Correspondence between those integers and bytes A byte is 8 bits and can encode any integer 0-255. 00000000 0 00000001 1 bytes integers 00000010 2 00000011 3 Variable-length encoding: integers vary in the number of bytes required to encode them. 11

  34. Representing Strings: UTF-8 Encoding UTF (UCS (Universal Character Set) Transformation Format) Unicode: Correspondence between characters and integers UTF-8: Correspondence between those integers and bytes A byte is 8 bits and can encode any integer 0-255. 00000000 0 00000001 1 bytes integers 00000010 2 00000011 3 Variable-length encoding: integers vary in the number of bytes required to encode them. In Python: string length is measured in characters, bytes length in bytes. 11

  35. Representing Strings: UTF-8 Encoding UTF (UCS (Universal Character Set) Transformation Format) Unicode: Correspondence between characters and integers UTF-8: Correspondence between those integers and bytes A byte is 8 bits and can encode any integer 0-255. 00000000 0 00000001 1 bytes integers 00000010 2 00000011 3 Variable-length encoding: integers vary in the number of bytes required to encode them. In Python: string length is measured in characters, bytes length in bytes. (Demo) 11

  36. Sequence Processing

  37. Sequence Processing 13

  38. Sequence Processing Consider two problems: 13

  39. Sequence Processing Consider two problems:  Sum the even members of the first n Fibonacci numbers. 13

  40. Sequence Processing Consider two problems:  Sum the even members of the first n Fibonacci numbers.  List the letters in the acronym for a name, which includes the first letter of each capitalized word. 13

  41. Sequence Processing Consider two problems:  Sum the even members of the first n Fibonacci numbers.  List the letters in the acronym for a name, which includes the first letter of each capitalized word. 13

  42. Sequence Processing Consider two problems:  Sum the even members of the first n Fibonacci numbers.  List the letters in the acronym for a name, which includes the first letter of each capitalized word. enumerate naturals: 13

  43. Sequence Processing Consider two problems:  Sum the even members of the first n Fibonacci numbers.  List the letters in the acronym for a name, which includes the first letter of each capitalized word. enumerate naturals: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11. 13

  44. Sequence Processing Consider two problems:  Sum the even members of the first n Fibonacci numbers.  List the letters in the acronym for a name, which includes the first letter of each capitalized word. enumerate naturals: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11. map fib: 13

  45. Sequence Processing Consider two problems:  Sum the even members of the first n Fibonacci numbers.  List the letters in the acronym for a name, which includes the first letter of each capitalized word. enumerate naturals: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11. map fib: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55. 13

  46. Sequence Processing Consider two problems:  Sum the even members of the first n Fibonacci numbers.  List the letters in the acronym for a name, which includes the first letter of each capitalized word. enumerate naturals: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11. map fib: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55. filter even: 13

  47. Sequence Processing Consider two problems:  Sum the even members of the first n Fibonacci numbers.  List the letters in the acronym for a name, which includes the first letter of each capitalized word. enumerate naturals: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11. map fib: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55. filter even: 13

  48. Sequence Processing Consider two problems:  Sum the even members of the first n Fibonacci numbers.  List the letters in the acronym for a name, which includes the first letter of each capitalized word. enumerate naturals: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11. map fib: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55. filter even: 0, 2, 8, 34, . 13

  49. Sequence Processing Consider two problems:  Sum the even members of the first n Fibonacci numbers.  List the letters in the acronym for a name, which includes the first letter of each capitalized word. enumerate naturals: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11. map fib: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55. filter even: 0, 2, 8, 34, . accumulate sum: 13

  50. Sequence Processing Consider two problems:  Sum the even members of the first n Fibonacci numbers.  List the letters in the acronym for a name, which includes the first letter of each capitalized word. enumerate naturals: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11. map fib: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55. filter even: 0, 2, 8, 34, . accumulate sum: ., ., ., ., =44 13

  51. Sequence Processing Consider two problems:  Sum the even members of the first n Fibonacci numbers.  List the letters in the acronym for a name, which includes the first letter of each capitalized word. 14

  52. Sequence Processing Consider two problems:  Sum the even members of the first n Fibonacci numbers.  List the letters in the acronym for a name, which includes the first letter of each capitalized word. 14

  53. Sequence Processing Consider two problems:  Sum the even members of the first n Fibonacci numbers.  List the letters in the acronym for a name, which includes the first letter of each capitalized word. enumerate words: 14

  54. Sequence Processing Consider two problems:  Sum the even members of the first n Fibonacci numbers.  List the letters in the acronym for a name, which includes the first letter of each capitalized word. enumerate words: 'University', 'of', 'California', 'Berkeley' 14

  55. Sequence Processing Consider two problems:  Sum the even members of the first n Fibonacci numbers.  List the letters in the acronym for a name, which includes the first letter of each capitalized word. enumerate words: 'University', 'of', 'California', 'Berkeley' filter capitalized: 14

  56. Sequence Processing Consider two problems:  Sum the even members of the first n Fibonacci numbers.  List the letters in the acronym for a name, which includes the first letter of each capitalized word. enumerate words: 'University', 'of', 'California', 'Berkeley' filter capitalized: 14

  57. Sequence Processing Consider two problems:  Sum the even members of the first n Fibonacci numbers.  List the letters in the acronym for a name, which includes the first letter of each capitalized word. enumerate words: 'University', 'of', 'California', 'Berkeley' filter capitalized: 'University', 'California', 'Berkeley' 14

  58. Sequence Processing Consider two problems:  Sum the even members of the first n Fibonacci numbers.  List the letters in the acronym for a name, which includes the first letter of each capitalized word. enumerate words: 'University', 'of', 'California', 'Berkeley' filter capitalized: 'University', 'California', 'Berkeley' map first: 14

  59. Sequence Processing Consider two problems:  Sum the even members of the first n Fibonacci numbers.  List the letters in the acronym for a name, which includes the first letter of each capitalized word. enumerate words: 'University', 'of', 'California', 'Berkeley' filter capitalized: 'University', 'California', 'Berkeley' map first: 'U', 'C', 'B' 14

  60. Sequence Processing Consider two problems:  Sum the even members of the first n Fibonacci numbers.  List the letters in the acronym for a name, which includes the first letter of each capitalized word. enumerate words: 'University', 'of', 'California', 'Berkeley' filter capitalized: 'University', 'California', 'Berkeley' map first: 'U', 'C', 'B' accumulate tuple: 14

  61. Sequence Processing Consider two problems:  Sum the even members of the first n Fibonacci numbers.  List the letters in the acronym for a name, which includes the first letter of each capitalized word. enumerate words: 'University', 'of', 'California', 'Berkeley' filter capitalized: 'University', 'California', 'Berkeley' map first: 'U', 'C', 'B' accumulate tuple: ( 'U', 'C', 'B' ) 14

  62. Mapping a Function over a Sequence Apply a function to each element of the sequence 15

  63. Mapping a Function over a Sequence Apply a function to each element of the sequence >>> alternates = (-1, 2, -3, 4, -5) 15

  64. Mapping a Function over a Sequence Apply a function to each element of the sequence >>> alternates = (-1, 2, -3, 4, -5) >>> tuple(map(abs, alternates)) 15

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