TOPIC 11 HTML (NOT AS ADVANCED) Max Fowler (Computer Science) - - PowerPoint PPT Presentation

topic 11 html not as advanced
SMART_READER_LITE
LIVE PREVIEW

TOPIC 11 HTML (NOT AS ADVANCED) Max Fowler (Computer Science) - - PowerPoint PPT Presentation

CS 105: TOPIC 10 LISTS (ADVANCED) TOPIC 11 HTML (NOT AS ADVANCED) Max Fowler (Computer Science) https://pages.github-dev.cs.illinois.edu/cs-105/web/ JULY 19, 2020 Week 6 Video Series Topics List Slices List Nesting List


slide-1
SLIDE 1

CS 105: TOPIC 10 – LISTS (ADVANCED) TOPIC 11 – HTML (NOT AS ADVANCED)

Max Fowler (Computer Science) https://pages.github-dev.cs.illinois.edu/cs-105/web/

JULY 19, 2020

slide-2
SLIDE 2

Week 6 Video Series Topics

List Slices List Nesting List Comprehensions Some basic HTML

slide-3
SLIDE 3

List Slicing

slide-4
SLIDE 4

Slicing Lists

 Just like with strings, we can slice lists – they're collections!  Same syntax  my_list = [1,2,3,4,5,6]  a_slice = [start_point:end_point]  As before, the end is not included

slide-5
SLIDE 5

As before…

 ml = [1,2,3,4,5]  new_slice = ml[:3]  ns_2 = ml[2:]  copy = ml[:]  copy == ml #True  copy is ml #False

[1,2,3] [3,4,5] [1,2,3,4,5] #but…

slide-6
SLIDE 6

Video question

 You are asked to slice between the first and second 5 in the

list a_list (including the 5s). What function lets you find the 5s?

 a_list = [1,2,5,4,2,5,1,1,2]

slide-7
SLIDE 7

List Nesting

slide-8
SLIDE 8

List Nesting

Like with loops, we can nest lists Effectively a "list of lists" [[3,4,5], [1,2,3], [2,1,3]] This is where nested loops come in as useful

too!

slide-9
SLIDE 9

Element access

A list of lists is like a table… al = [[1,2,3], [4,5,6], [7,8,9] So what is al[1][1]?

1 2 3 4 5 6 7 8 9

slide-10
SLIDE 10

Best with example, so…

Coding example 1: Let's write a function which takes a list of lists. It

should return the sum of ALL of the even numbers in the list

slide-11
SLIDE 11

More examples!

Coding example 2: Let's write a function which takes a list of lists. It

should return the index of the sublist with the LARGEST sum

slide-12
SLIDE 12

Video Question my_list = [ ['a', 'b', 'c'], ['d', 'e', 'f'], ['g', 'h', 'i'] ] x = my_list[1][2] What is the value of x?

slide-13
SLIDE 13

List Comprehensions

slide-14
SLIDE 14

List comprehensions

Syntactic sugar – write things more efficiently It's okay not to understand it…but it's pretty dope [expression for value in sequence] [expression for value in sequence if condition] I showed it off on one of the Wednesday class

meetings

slide-15
SLIDE 15

Two examples…

Using a list comprehension, let's do the following:

Write a function which, given a list, returns a version

with all uppercase versions of each string

Write a function which, given a list, returns the absolute

value of ALL odd numbers in the list

slide-16
SLIDE 16

No Video Question You may have list comp on homework for practice, but you can always use a regular loop to do the same things!!

slide-17
SLIDE 17

What is HTML?

slide-18
SLIDE 18

What is HTML?

 HTML is

HyperText Markup Language

 Not a programming language in the regular sense  Describes web page content using HTML tags

slide-19
SLIDE 19

What HTML interactions will you have in this class?

Summer is fast…pretty late in the semester to

have y'all code big web pages!

You will have:

A lab (at least one) Some parsons problems Some Python problems "writing" HTML tags as

strings

slide-20
SLIDE 20

Syntax Differences Between HTML & Python (20.2-3)

Really important in Python. Ex: for item in list: print(item) Versus for item in list: print(item) Optional, used just for clarity in

  • HTML. Ex: both of these produce

same result: <ul> <li>A list item.</li> <li>Another list item.</li> </ul> <ul><li>A list item.<li><li>Another list item.</li></ul> Whitespace (spaces, tabs, newlines)

Causes IndentationError Runs correctly

slide-21
SLIDE 21

Syntax Differences Between HTML & Python (20.2-3)

Python Use # for single line comments: # this is a comment new_list = [“coconut”, “butter”, “flour”] # this is another comment Need # at beginning of every new line of comments HTML Use <!-- and --> for comments: <p>A demonstration of comments</p> <!-- This is a comment which can span over as many lines as we want. It only ends when the end comment notation is used. --> <p>The demonstration is over.</p> Comments

slide-22
SLIDE 22

Very Simple Web Page

I thought it might be useful to show off making a

simple web page

I will do so in Notepad++ Will feature

A header Bold and italic text an image

slide-23
SLIDE 23

No Video Question

Doesn't make sense to ask one about HTML,

largely a side/interest topic