Class 12 – Monday, February 14

Loops and Indexing


Look both ways


Agenda


Downloads


Program half_scores.py

  • Cast string to int, then append it to the int list.
  • Add that number to the running total of the first quiz scores.
  • Add that number to the running total of the last quiz scores.

Enter scores: 100 90 85 60 77 44 99 100

First half score: 83.75

Second half score: 80.0


Program on_average.py

  • Compute length of the current word of interest.
  • Add that length to running total of the word lengths.

Enter text: over the hill and through the dale

words = ['over', 'the', 'hill', 'and', 'through', 'the', 'dale']

Average word length: 4.0

Enter text: row row row your boat

words = ['row', 'row', 'row', 'your', 'boat']

Average word length: 3.4



Program thats_printastic.py

Wa-Hoo-Wa

Rah-Rah-Rah

Wa-Hoo-Wa!Rah-Rah-Rah

Wa-Hoo-Wa! Rah-Rah-Rah

s-a-i-p-p-u-a-k-i-v-i-k-a-u-p-p-i-a-s-.

s a i p p u a k i v i k a u p p i a s .

saippuakivikauppias.



Program c_looper.py

row : 0 1 2 ... n-1

Enter number of columns: 5

row : 0 1 2 3 4


Enter number of columns: 12

row : 0 1 2 3 4 5 6 7 8 9 10 11



Program dataset_intro.py

table: [['A', 'B', 'C'], ['D', 'E', 'F'], ['G', 'H', 'I'], ['J', 'K', 'L', 'M']]

the table has 4 rows

row ['A', 'B', 'C'] has 3 columns

row ['D', 'E', 'F'] has 3 columns

row ['G', 'H', 'I'] has 3 columns

row ['J', 'K', 'L', 'M'] has 4 columns

row 0 : ['A', 'B', 'C']

row 1 : ['D', 'E', 'F']

row 2 : ['G', 'H', 'I']

row 3 : ['J', 'K', 'L', 'M']

 


  🦆 © 2022 Jim Cohoon   Resources from previous semesters are available.