CSC 120 L101 Practice Midterm #1
Instructor: Elizabeth Patitsas
February 4, 2015
Last name:
First name:
Your utorid:
Your lab section:
TUESDAY 3-5pm
or
5-7pm
(circle one)
You have 50 minutes to write
CSC 120 L101 Midterm #1
Instructor: Elizabeth Patitsas
February 4, 2015
Last name:
First name:
Your utorid:
Your lab section:
TUESDAY 3-5pm
or
5-7pm
(circle one)
You have 50 minutes to write the exam
CSC120 Lecture 11 If Statements
1
The if statement
In everyday life, we often make decisions based on the current conditions.
If the weather is warm,
I wear shorts.
Otherwise,
I wear pants.
The same c
CSC120 Lecture 8 - Indexing and Slicing Numpy Arrays
1
Indexing
Everything in a numpy array has an index. What will these lines of code do?
s = np.array([1, 2, 3])
s[0]
s[1:]
s[:]
s[-1:]
Negative numb
CSC120H Lab 1
1
Objectives
1. Practice using variables
2. Practice running and editing Python programs
3. Practice writing functions
4. Practice translating mathematical functions into Python ones
2
M
CSC120H Lab 6
Objectives
1. Practice with iteration
2. Practice with strings
3. Practice with lists
4. Turtles turtles turtles
Preparation
Before doing this lab, you should be able to:
1. Write a for
CSC120H Lab 2
Objectives
1. Practice with helper functions
2. Practice writing docstrings, including doctests
3. Practice implementing functions
4. Practice debugging provided functions
5. Practice tr
CSC 120H1S Practice Final Exam
Instructor: Elizabeth Patitsas; Term: Winter 2015
Last name:
First name:
Your utorid:
Student number:
You have 2 hours to write the exam.
You are not permitted any aids,
CSC 120H1S Practice Final Exam
Instructor: Elizabeth Patitsas; Term: Winter 2014
Last name:
First name:
Your utorid:
Student number:
You have 3 hours to write the exam.
You are not permitted any aids,
Midterm #1 sample solutions
1. def calendar_difference(year):
(int) -> int
Return the how far the year in the Gregorian calendar
is from the Julian calendar.
> calendar_difference(2014)
13
> calendar_
CSC120 Lecture 15 Lists
1
Lists: Introduction and indexing
Earlier this term we saw numpy arrays, which allowed us to represent collections of numbers. However, arrays can only contain things of one p
CSC120 Lecture 14 String Methods
1
Methods
We have been using some string operators such as:
csc + 120
"hi" * 3
"ou" in "colour"
There are many more! so many, in fact, that there arent enough operator
CSC120 Lecture 13 Iterating over Strings
1
Strings
Python represents text as strings, which are sequences of characters. We have used some strings
already this term; in our next couple of lectures we
CSC120H Lab 7
Objectives
1. Practice with the os module
2. Practice with reading tab delimited les
Preparation
Before doing this lab, you should be able to:
1. Open les with numpys genfromtxt using mu
CSC120 Lecture 12 Logic Operators
1
1.1
Working with Booleans
Boolean variables
Suppose that snowing and sunny are of type bool. They can be either True or False.
snowing = False
sunny = True
temperat
CSC120 Lecture 23 Lists
A list is a collection type in Python, and give us an alternative to arrays.
To create a list, enclose its contents in []s, and separate the entities with commas. For example:
CSC120 Lecture 24 Paramater Passing and Raising/Catching Exceptions
In this lecture we will start by covering a few small things that will be helpful for your assignment,
then well focus on exceptions
CSC120H Lab 4
Objectives
1. Practice with le reading
2. Practice with numpy arrays, particularly ltering
3. Practice with if-statements
4. Introduction to discrete-event simulation
Marking
Every lab w
CSC120H Lab 8
Objectives
1. Practice with sqlite
2. Practice selecting from tables using where
3. Practice performing joins
Preparation
Before doing this lab, you should be able to:
1. Write select st
CSC120 Lecture 3 Functions
So far we have been working in the console of Spyder, which allows us to execute lines of code one
by one. But what if we want to run multiple lines of code at a time? In th
CSC 120: Computer Science for the Sciences (R section)
Radford M. Neal, University of Toronto, 2015
http:/www.cs.utoronto.ca/radford/csc120/
Week 5
Environments
An R environment is a collection of var
CSC 120: Computer Science for the Sciences (R section)
Radford M. Neal, University of Toronto, 2015
http:/www.cs.utoronto.ca/radford/csc120/
Week 7
Adding Attributes to R Objects
An R object can have
CSC 120: Computer Science for the Sciences (R section)
Radford M. Neal, University of Toronto, 2015
http:/www.cs.utoronto.ca/radford/csc120/
Week 8
Names and NA Two R Features for Statistics
R is a ge
CSC 120: Computer Science for the Sciences (R section)
Radford M. Neal, University of Toronto, 2015
http:/www.cs.utoronto.ca/radford/csc120/
Week 3
Making Functions Do Dierent Things, Using if
When yo
CSC 120: Computer Science for the Sciences (R section)
Radford M. Neal, University of Toronto, 2015
http:/www.cs.utoronto.ca/radford/csc120/
Week 10
Operations on Vectors
Weve seen before that R can d
CSC 120: Computer Science for the Sciences (R section)
Radford M. Neal, University of Toronto, 2015
http:/www.cs.utoronto.ca/radford/csc120/
Week 12
Statistical Facilities in R
In this course, weve mo
CSC 120: Computer Science for the Sciences (R section)
Radford M. Neal, University of Toronto, 2015
http:/www.cs.utoronto.ca/radford/csc120/
Week 11
Another Use for Classes Factors
Recall that how R h
CSC 120: Computer Science for the Sciences (R section)
Radford M. Neal, University of Toronto, 2015
http:/www.cs.utoronto.ca/radford/csc120/
Week 9
Random Numbers and Their Uses
Random variation is a
Union-Find Data Structure
In computer science, a unionfind data structure, also called a disjoint-set data structure or merge
find set, is a data structure that keeps track of a set of elements partit