review-10 - Oct 6 2010 CMSC143 - O'Hara 1 CMSC 143 M idter...

Info iconThis preview shows pages 1–12. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Oct 6 2010 CMSC143 - O'Hara 1 CMSC 143 M idter m Review Keith O’Hara [email protected] Oct 6 2010 CMSC143 - O'Hara 2 Administrative Midterm – Friday, October 8 Assignment 3 – October 15th Oct 6 2010 CMSC143 - O'Hara 3 Midterm You and a pencil Closed Books Closed Notes Closed Laptops Closed Neighbors Closed Robot! 80 minutes Python Terminology Reading Programs Writing Programs Robots homework material is fair game Topics Expressions Variables Functions For & While loops Conditionals Recursion Lists Objects Oct 6 2010 CMSC143 - O'Hara 4 Oct 6 2010 CMSC143 - O'Hara 5 Operators Python has many operators. Some examples are: +, -, *, /, %, >, <, == print Operators perform an action on one or more operands. Some operators accept operands before and after themselves: operand1 + operand2 , or 3 + 5 Others are followed by one or more operands until the end of the line, such as: print “Hi!”, 32, 48 When operators are evaluated, they perform action on their operands, and produce a new value. Oct 6 2010 CMSC143 - O'Hara 6 Expressions Code snippets that evaluate to some value . 3+2 3*2 3**2 (3+2)*(4+2) 3.0/2.0 “hello” + “world” Oct 6 2010 CMSC143 - O'Hara 7 What’s the Type? -1 -1.5 30000 “30000” 30000.0 3.14 [-1, -1.5, “30000”] Oct 6 2010 CMSC143 - O'Hara 8 Types of Values Integers (like integers in math) -1, -2, 300000, 0 Float ing Points (like “decimals”) -1.5, 1.5, 3.1415, 1.0 Character (like symbol of an alphabet) ‘a’, ‘b’, ‘c’, ‘z’ Strings (a string of characters) “CMSC”, “143”, “rocks”, “” Lists (a collection of values) [“CMSC”, “143”, “rocks”]; [-1, -2, 3000]; type(“rocks”), type(10) Oct 6 2010 CMSC143 - O'Hara 9 Integer Arithmetic Addition (+) Subtraction (-) Multiplication (*) Integer Division (/) 4/2 5/2 Modulo/Remainder(%) 4%2 5%2 Exponentiation (**) 2**3 2**4 Integer Division (/) 4/2 # evals to 2 5/2 # evals to 2 Modulo/Remainder(%) 4%2 # evals to 0 5%2 # evals to 1 Exponentiation (**) 2**3 # evals to 8 2**4 # evals to 16 Oct 6 2010 CMSC143 - O'Hara 10 Float Arithmetic Addition (+) Subtraction (-) Multiplication (*) Integer Division (/) 4.0/2.0 5.0/2.0 Modulo/Remainder(%) 4.0%2.0 5.0%2.0 Exponentiation (**) 2.0**3.0 2.0**4.0 Integer Division (/) 4.0/2.0 # evals to 2.0 5.0/2.0 # evals to 2.5 Modulo/Remainder(%) 4.0%2.0 # evals to 0.0 5.0%2.0 # evals to 1.0 Exponentiation (**) 2.0**3.0 # evals to 8.0 2.0**4.0 # evals to 16.0 Oct 6 2010 CMSC143 - O'Hara 11 Sequence “Arithmetic” Addition (+) - Combines (concatenates) the sequence “CMSC” + “143” # evals to “CMSC143” Multiplication (*) - Repeats the sequence “CS” *3 # evals to “CSCSCS” Oct 6 2010...
View Full Document

This note was uploaded on 10/14/2010 for the course CMSC 143 taught by Professor Keitho'hara during the Spring '10 term at Bard College.

Page1 / 57

review-10 - Oct 6 2010 CMSC143 - O'Hara 1 CMSC 143 M idter...

This preview shows document pages 1 - 12. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online