Presentation is loading. Please wait.

Presentation is loading. Please wait.

MCS 177 Lab Fall 2014 Sept. 2, 2014. GUSTAVUS ADOLPHUS COLLEGEgustavus.edu Contact Info Course Instructor: Louis Yu Lab.

Similar presentations


Presentation on theme: "MCS 177 Lab Fall 2014 Sept. 2, 2014. GUSTAVUS ADOLPHUS COLLEGEgustavus.edu Contact Info Course Instructor: Louis Yu Lab."— Presentation transcript:

1 MCS 177 Lab Fall 2014 Sept. 2, 2014

2 GUSTAVUS ADOLPHUS COLLEGEgustavus.edu Contact Info Course Instructor: Louis Yu lyu@gustavus.edulyu@gustavus.edu Lab Instructors: Mike Hvidsten hvidsten@gustavus.eduhvidsten@gustavus.edu Jeff Engelhardt jengelha@gustavus.edujengelha@gustavus.edu Lab Assistants 11:30: Andrew Haisting (ahaistin@gustavus.edu)ahaistin@gustavus.edu 2:30: Dustin Luhmann (dluhmann@gustavus.edu)dluhmann@gustavus.edu MCS 177, 9/2/14

3 GUSTAVUS ADOLPHUS COLLEGEgustavus.edu 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) MCS 177, 9/2/14

4 GUSTAVUS ADOLPHUS COLLEGEgustavus.edu Course/Lab Course Website: www.gac.edu/~lyu/teaching/mcs177-f14/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 www.gac.edu/~hvidsten/courses/MC177 MCS 177, 9/2/14

5 GUSTAVUS ADOLPHUS COLLEGEgustavus.edu 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 MCS 177, 9/2/14

6 GUSTAVUS ADOLPHUS COLLEGEgustavus.edu Why Python? MCS 177, 9/2/14 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 pre- defined types

7 GUSTAVUS ADOLPHUS COLLEGEgustavus.edu Idle GUI Environment: MCS 177, 9/2/14

8 GUSTAVUS ADOLPHUS COLLEGEgustavus.edu Let’s Get Started! Log on to your computer (user name = email name) Start Idle Try some basic arithmetic examples MCS 177, 9/2/14

9 GUSTAVUS ADOLPHUS COLLEGEgustavus.edu Arithmetic Operations MCS 177, 9/2/14 OperatorOperation +Addition -Subtraction *Multiplication /Float division //Integer division %Remainder **Exponentiation abs()Absolute value

10 GUSTAVUS ADOLPHUS COLLEGEgustavus.edu 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) MCS 177, 9/2/14

11 GUSTAVUS ADOLPHUS COLLEGEgustavus.edu Numerical Operations >>> 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 MCS 177, 9/2/14 Operations on ints produce ints (except for /) Operations on floats produce floats, Mixed operations are converted to floats

12 GUSTAVUS ADOLPHUS COLLEGEgustavus.edu Variable Assignment (Section 1.5) MCS 177, 9/2/14 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

13 GUSTAVUS ADOLPHUS COLLEGEgustavus.edu Example MCS 177, 9/2/14 We want to calculate the volume of a cylinder volume = area of base * height Variables?

14 GUSTAVUS ADOLPHUS COLLEGEgustavus.edu Example MCS 177, 9/2/14

15 GUSTAVUS ADOLPHUS COLLEGEgustavus.edu Diagram for Simple Assignment in Python MCS 177, 9/2/14

16 GUSTAVUS ADOLPHUS COLLEGEgustavus.edu Changing Radius value has no effect on cylinderVolume! Why not? MCS 177, 9/2/14 10.0

17 GUSTAVUS ADOLPHUS COLLEGEgustavus.edu How do we make change? MCS 177, 9/2/14 Need to re-evaluate baseArea and cylinderVolume

18 GUSTAVUS ADOLPHUS COLLEGEgustavus.edu If time, Start working on Tasks 1 and 2 of Project 1 MCS 177, 9/2/14


Download ppt "MCS 177 Lab Fall 2014 Sept. 2, 2014. GUSTAVUS ADOLPHUS COLLEGEgustavus.edu Contact Info Course Instructor: Louis Yu Lab."

Similar presentations


Ads by Google