Laboratory Assignments
Weeks 1/2
Lab 1
Lab 2
Linux
Quiz Preparation
Week 3
Lab 3
Input in Python:
- For integers use: int(input("user prompt "))
- For floats use: float(input("user prompt "))
- For strings use: input("user prompt ") and when inputing the string
you must enclose it in double or single quotes
- For formatted output use function format.
- For example, to print only 2 decimal digits of the number
1232.566777 use the
following statement:
print(format(1232.566777, '.2f'))
- For example, to print only 4 decimal digits of the number 1232.566777
use the
following statement:
print(format(1232.566777, '.4f'))
Lab 4
Lab Wed Sept 16
Lab Practice Monday Sept 23: if-else PART I
Lab Practice Sept 27
if-else lab PART II
Oct 2 Lab Assignment Version 1
Oct 2 Lab Assignment Version 2
Test 2 Preparation and Lab Practice - Oct 4
LOOP WHILE
Lab Part I
Lab Part II
Lab Part III
Mini Quiz Oct 18
version 1
version 2
Mini Quiz Oct 25
version 1
version 2
Exam 3
Exam 3 Version 1
Exam 3 Version 2
Functions
Functions Practice Lab
Functions Practice - Nov 8
Lab Assignment Nov 8
Lab Assignment Nov 8
Lab Practice - Functions - Nov 13/15
Lab Practice - Graded
Graded Practice Nov 13
Lab Practice - Graded
Lab
Lab Practice - Session B
lab practice session B
One Dimensional Lists
Lab Practice - Lists - Part I
test Prep
- Problem 1: Write a function change with 4 parameters: change(q,
d, n, p) where q = #quarters, d = #dimes, n = #nickels and p = #pennies.
This function should return the equivalent dollar amount. For example, 1
quarter, 2 dimes, 3 nickels and 5 pennies = $ 0.65. Write main to test
your function
- Problem 2: Write function circ that has two parameters:
sides of rectangle, function returns the circumference of the rectangle
using the following formula: circ=2*(side1+side2). Write function area
that has two parameters:
sides of rectangle, function returns the area of
rectangle using the following formula: area=side1*side2.
Write function called combine that has one parameter - number of
rectangles to process. The function will ask user to enter sides of
reactangle for each rectangle and print area and circumference for each
rectangle - use function circ and area to calculate area and
circumference. In addition, function returns the max circumference and the
max area. Write main to test your function
Exam 4
One Dimensional Lists
Lists Practice Part II
One Dimensional Lists - 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.
Thanksgiving Homework - Due Day Dec 2- Graded as Lab Assignment
Homework
Make up
make up
Lists in Python Documentation
Lists in Python Documentation
Make up
make up 1
Lab Assignment Wed Dec 4