Class 16 — Wednesday March 10

CSV Chrestomathics and logical values and decision

May the light of peace — For you and your families — Always shine brightly


Look both ways


Riddle me this — what classrooms are viable for scheduling CS 1112


Agenda


Transitioning


Downloads


To do


Program can_you_relate.py

Three program runs

Enter number: 12

Enter number: 11

12 < 11 : False

12 > 11 : True

12 <= 11 : False

12 >= 11 : True

12 == 11 : False

12 != 11 : True

Enter number: 3

Enter number: 14

3 < 14 : True

3 > 14 : False

3 <= 14 : True

3 >= 14 : False

3 == 14 : False

3 != 14 : True

Enter number: 7

Enter number: 7

7 < 7 : False

7 > 7 : False

7 <= 7 : True

7 >= 7 : True

7 == 7 : True

7 != 7 : False



Program logical_operators.py

Program run

##### Logical values (bool)

True

False

##### Logical and

True and True = True

True and False = False

False and True = False

False and False = False

##### Logical or

True or True = True

True or False = True

False or True = True

False or False = False

##### Logical negation

not True = False

not False = True

##### Logical includes

1 in [3, 1, 4, 1, 5] = True

2 in [3, 1, 4, 1, 5] = False

##### Logical exclusion

1 not in [3, 1, 4, 1, 5] = False

2 not in [3, 1, 4, 1, 5] = True



Program acid_test.py

Three program runs

Enter pH level: 6.5

True

Enter pH level: 7.0

False

Enter pH level: 7.5

False



Some datasets

Location, Author, Max Height, Min Height

Narnia, Lewis, 4810, -10

Neverland, Milne, 426, -2

Oz, Baum, 1231, 679

Sleepy Hollow, Irving, 1629, 304

Stars Hollow, Sherman-Palladino, 725, 152

Toyland, MacDonough, 6187, 0

Wonderland, Carroll, 5895, -5

Country, Females, Males

Australia, 11175724, 11092660

Fiji, 421365, 439258

French Polynesia, 132082, 138682

New Caledonia, 125322, 125548

New Zealand, 2223281, 2144855

Papua New Guinea, 3359979, 3498287

Solomon Islands, 259909, 278239

Vanuatu, 117573, 122078



Program csv_is_not_a_pharmacy.py — streamlining getting a dataset

Enter name of dataset: oceania.csv

dataset:

Country, Females, Males

Australia, 11175724, 11092660

Fiji, 421365, 439258

French Polynesia, 132082, 138682

New Caledonia, 125322, 125548

New Zealand, 2223281, 2144855

Papua New Guinea, 3359979, 3498287

Solomon Islands, 259909, 278239

Vanuatu, 117573, 122078

header:

['Country', 'Females', 'Males']

data:

['Country', 'Females', 'Males']

['Australia', 11175724, 11092660]

['Fiji', 421365, 439258]

['French Polynesia', 132082, 138682]

['New Caledonia', 125322, 125548]

['New Zealand', 2223281, 2144855]

['Papua New Guinea', 3359979, 3498287]

['Solomon Islands', 259909, 278239]

['Vanuatu', 117573, 122078]

Enter name of dataset: elevations.csv

dataset:

Location, Author, Max Height, Min Height

Narnia, Lewis, 4810, -10

Neverland, Milne, 426, -2

Oz, Baum, 1231, 679

Sleepy Hollow, Irving, 1629, 304

Stars Hollow, Sherman-Palladino, 725, 152

Toyland, MacDonough, 6187, 0

Wonderland, Carroll, 5895, -5

header:

['Location', 'Author', 'Max Height', 'Min Height']

data:

['Narnia', 'Lewis', 4810, -10]

['Neverland', 'Milne', 426, -2]

['Oz', 'Baum', 1231, 679]

['Sleepy Hollow', 'Irving', 1629, 304]

['Stars Hollow', 'Sherman-Palladino', 725, 152]

['Toyland', 'MacDonough', 6187, 0]

['Wonderland', 'Carroll', 5895, -5]



Where am I

jpc @ love is love

 


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