j

Course and Reading Material

One Dimensional Lists and Strings in Python

Formating floating point: b=float("{0:.2f}".format(a))

Tentative Future Plans

Mini Quiz 1 Preparation

Solution Mini Quiz 1 Preparation

Mini Quiz 1 January 27, 2017 - HTML file
Mini Quiz 1 January 27, 2017 - template file

Lecture Practice

The Community Center in City A offers a wide range of activities: various group exercise classes, gym, swimming pool, personal training, etc. For each activity, the Center publishes the number of calories could be burnt during 1 hour of exercise. Write a program that reads the number of activities a person participated during one week. The program creates a list of activity names - list of strings - user input. The program also randomly generates a list of integers - number of hours spent on each activity per week. The program also randomly generates a list of integers - the number of calories that could be burnt for 1 hour for each activity. The program creates a new list - total_calories. Each entry in the list is the total number of calories burnt per week per activity. The program also finds the activity with minimal number of calories burnt per week.
See example below:

activity_names=["Yoga", "Tai-Chi", "Swimming", "Running", "Walking"]

calories_per_hour=[154, 240, 400, 600, 340]

hours_per_week=[6, 3, 2, 2, 3]

total_calories=[924, 720, 800, 1200, 1020]

the activity with minimal calories burnt per week - Tai-Chi, with 720 calories burnt per week.


Make List and Make String Functions to use in your programs


Test 1 Preparation


Lecture Practice

Test 1 Preparation



Test 1

Test 1 Solution Problem 1



Lecture/Lab Practice - Monday Feb 13


test 1 Wed Feb 17


Two Dimensional Lists

List Initialization

Option 1:
a = [[ 0 for i in range(COL)] for j in range(ROW)]
The above line will create a list of ROW rows and COL columns and assign value 0 to each element

Option 2

Generating Random 2d list of integers

Make List and Print 2d List in Table Form

Lecture Practice - Working with 2d list of integers



Two-Dimensional Lists: Lecture and Lab Practice