DOC PREVIEW
TAMU CSCE 110 - Introduction to Python/Python Basics
Type Lecture Note
Pages 4

This preview shows page 1 out of 4 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 4 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 4 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

CSCE 110 1nd EditionLecture 1Outline of Current Lecture:I. Getting StartedA. BasicsB. Types of input/outputII: OperatorsA. Mathematical OperatorsB. Comparison OperatorsC. Conjunctive OperatorsCurrent LectureI: Getting StartedIt is important to understand that if there is one mistake in the beginning of your code, the entire program and output will be affected by the error. It is important that you try writing multiple programs in Python in order to see where these mistakes may arise.You will need to download both Enthought and Wingware on your computer to write code at home. Here are the URLs:https://www.enthought.com/products/epd/free/At the time of this writing, Enthought uses version 2.7 of Python. http://wingware.com/downloads/wingide-101/5.0.0-b6/binariesProgramming is the process of going from input to output, using written instructions.The first key function of Python we will learn about is the print function. We must type the word"print" and then, in quotations, something we wish to see printed. We can do this is in several different ways. For example, if we wanted to print the phrase "Hello, World!", our program could look like any of the following:>>> print "Hello, World!">>> print 'Hello, World!'>>> print '''Hello, World!'''If we choose any of those methods, we are printing what is called a string. A string can be comprised of any character (aside from the key function names of Python that will be discussed These notes represent a detailed interpretation of the professor’s lecture. GradeBuddy is best used as a supplement to your own notes, not as a substitute.in the next set of lecture notes). An integer and float are both types of numbers; we'll elaborate in Part II. A Boolean is an expression that is either True or False. II: OperatorsA. We can also use Python to compute mathematical problems, such as:>>> 3 + 4>>> 3 / 1>>> 12 * 10 + 4If there are multiple mathematical computations in one line, Order of Operations is followed (Parentheses, Exponents, Multiplication or Division, Addition or Subtraction - PEMDAS)These are the different mathematical operators in Python:+ Addition- Subtraction* Multiplication/ Division** Exponentiation (Number ** Exponent)% Modulus/Remainder (Number % Divisor, and will give us a remainder, NOT quotient)Here are some examples of inputs/outputs:>>> 3 + 4>>> 7>>> 10 % 7>>> 3>>> 3 ** 3>>> 27>>> 10 + 2 * 4>>> 18>>> 1 / 3>>> 0 This is because we only used integers in our mathematical expression, so the answer will also beinteger (incorrect or not). To get an accurate answer, we must use decimal places in our numbers, or floats.>>> 1 / 3.0>>> 0.333333333333B. We can also compare different values in Python.These are the different comparison operators in Python:< less than<= less than or equal to> greater than>= greater than or equal to== equal to!= not equal toHere are some examples of inputs/outputs:>>> 3 < 5>>> True>>> 10 >= 10>>> True>>> 2 != 2>>> False>>> 12.1 > 12.6>>> FalseC. We can also have code that looks at multiple expressions.These are the different conjunctive operators in Python:and Two thingsor One of two thingsnot Neither of two thingsHere are some examples of inputs/outputs:>>> 3>5 and 3>2>>> FalseBoth expressions must be correct to return True>>> 3>5 or 3>2>>> TrueEither of the expressions must be correct to return True>>> not 3>5>>> True>>> not 5>6 and 5>6>>> FalseObviously it is impossible for both of the expressions to be


View Full Document

TAMU CSCE 110 - Introduction to Python/Python Basics

Type: Lecture Note
Pages: 4
Documents in this Course
06-IO

06-IO

29 pages

21-OOP

21-OOP

8 pages

key

key

6 pages

21-OOP

21-OOP

8 pages

Load more
Download Introduction to Python/Python Basics
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Introduction to Python/Python Basics and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Introduction to Python/Python Basics 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?