Download Course Website - Gustavus Adolphus College

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
MCS 177 Lab Fall 2014
Sept. 2, 2014
MCS 177, 9/2/14
Contact Info
• Course Instructor: Louis Yu
[email protected]
• Lab Instructors:
• Mike Hvidsten [email protected]
• Jeff Engelhardt [email protected]
• Lab Assistants
11:30: Andrew Haisting ([email protected])
2:30: Dustin Luhmann ([email protected])
GUSTAVUS ADOLPHUS COLLEGE
gustavus.edu
MCS 177, 9/2/14
Today’s schedule
• Course/Lab Details
• Python and Idle
• Python Intro (Sec 1.1-1.5 in textbook)
• Tasks 1 and 2 of Project 1 (if time)
GUSTAVUS ADOLPHUS COLLEGE
gustavus.edu
MCS 177, 9/2/14
Course/Lab
• Course Website: www.gac.edu/~lyu/teaching/mcs177-f14/
• Lectures – Monday, Wednesday, Friday
• Read Assigned sections before class (see class schedule)
• Lab Work – Tuesday, Thursday
• Projects are linked from course site
• This week – Intro (nothing to hand in)
• Submit code via Moodle
• Lab notes/slides at www.gac.edu/~hvidsten/courses/MC177
GUSTAVUS ADOLPHUS COLLEGE
gustavus.edu
MCS 177, 9/2/14
Python – Course Programming Language
• Python is an open source scripting language.
• Developed by Guido van Rossum in the early 1990s
• Named after Monty Python
• Available on MCS computers
• Available for download from
http://www.python.org
GUSTAVUS ADOLPHUS COLLEGE
gustavus.edu
MCS 177, 9/2/14
Why Python?
• Simple Syntax – we can focus on solving problems,
learning concepts, not coding syntax
• Object-Oriented – all values are essentially objects
• Widely used (Google spider and search engine)
• Powerful String and Math libraries
• Dynamic Typing: Variables do not need to have predefined types
GUSTAVUS ADOLPHUS COLLEGE
gustavus.edu
MCS 177, 9/2/14
Idle GUI Environment:
GUSTAVUS ADOLPHUS COLLEGE
gustavus.edu
MCS 177, 9/2/14
Let’s Get Started!
• Log on to your computer (user name = email name)
• Start Idle
• Try some basic arithmetic examples
GUSTAVUS ADOLPHUS COLLEGE
gustavus.edu
MCS 177, 9/2/14
Arithmetic Operations
Operator
Operation
+
Addition
-
Subtraction
*
Multiplication
/
Float division
//
Integer division
%
Remainder
**
Exponentiation
abs()
Absolute value
GUSTAVUS ADOLPHUS COLLEGE
gustavus.edu
MCS 177, 9/2/14
Numerical Data Types
• Integer (int) vs
Floating Point (float)
• How can we tell which is which?
A numeric value without a decimal point produces an int
value
A numerical value that has a decimal point is represented
by a float (even if the fractional part is 0)
GUSTAVUS ADOLPHUS COLLEGE
gustavus.edu
MCS 177, 9/2/14
Numerical Operations
Operations on ints produce ints (except for /)
Operations on floats produce floats,
Mixed operations are converted to floats
>>> 3.0+4.0
7.0
>>> 3+4
7
>>> 3.0*4
12.0
>>> 3*4
12
>>> 10.0/3.0
3.3333333333333335
>>> 10/3
3.3333333333333335
>>> 10 // 3
3
>>> 10.0 // 3.0
3.0
GUSTAVUS ADOLPHUS COLLEGE
gustavus.edu
MCS 177, 9/2/14
Variable Assignment (Section 1.5)
• As in mathematics, much of the power of computer
programs is in the use of variables
• Python variables are identified by name
• Must start with a letter
• Ex: x=2, a_1 = x+3
GUSTAVUS ADOLPHUS COLLEGE
gustavus.edu
MCS 177, 9/2/14
Example
• We want to calculate the volume of a cylinder
• volume = area of base * height
• Variables?
GUSTAVUS ADOLPHUS COLLEGE
gustavus.edu
MCS 177, 9/2/14
Example
GUSTAVUS ADOLPHUS COLLEGE
gustavus.edu
MCS 177, 9/2/14
Diagram for Simple Assignment in Python
GUSTAVUS ADOLPHUS COLLEGE
gustavus.edu
MCS 177, 9/2/14
Changing Radius value has no effect on cylinderVolume!
Why not?
10.0
GUSTAVUS ADOLPHUS COLLEGE
gustavus.edu
MCS 177, 9/2/14
How do we make change?
• Need to re-evaluate baseArea and cylinderVolume
GUSTAVUS ADOLPHUS COLLEGE
gustavus.edu
MCS 177, 9/2/14
If time, Start working on Tasks 1 and 2 of Project 1
GUSTAVUS ADOLPHUS COLLEGE
gustavus.edu
Related documents