1 / 8

computer science

CSCI 1001. overview of. computer science. PYTHON III. LISTS. are ordered sequences of values. students = [‘Carol’, ‘Bob’ , ‘Alice’, ‘Dave’]. ages = [20, 18, 17, 26]. students[1]. → ‘Bob’. ages[0]. → 20. ages = [20, 18, 17, 26]. for a in ages: print a. ages[1].

gyda
Download Presentation

computer science

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CSCI 1001 overview of computer science PYTHON III

  2. LISTS are ordered sequences of values. students = [‘Carol’, ‘Bob’, ‘Alice’, ‘Dave’] ages = [20, 18, 17, 26] students[1] → ‘Bob’ ages[0] → 20

  3. ages = [20, 18, 17, 26] for a in ages: print a ages[1] ages[1] = 19 #Happy Birthday! len(ages)

  4. ages = [20, 18, 17, 26] ages.append(21) ages[1:3] more_ages = [23, 18, 19] ages + more_ages

  5. ages = [20, 18, 17, 26] 17 in ages ages.index(17) sum(ages) range(0,10,2)

  6. Acceptable Ages Function Take a list of pairs of ages (a,b). For each couple that is “creepy”, print a message saying the pair is creepy. At the end print out the number of couples that are not creepy.

  7. Guessing Game Function Take a secret number as an argument. Ask user to guess it 3 times. Tell user whether guess is too low or high Congratulate them if they win! (Tell them the rules!)

  8. http://cs1001.us/ Please read Sections 3-5 of the Python chapter for Friday

More Related