New User Special Price Expires in

Let's log you in.

Sign in with Facebook


Don't have a StudySoup account? Create one here!


Create a StudySoup account

Be part of our community, it's free to join!

Sign up with Facebook


Create your account
By creating an account you agree to StudySoup's terms and conditions and privacy policy

Already have a StudySoup account? Login here

RPI Computer Science I Week 1-2 Notes

by: Chris Fall

RPI Computer Science I Week 1-2 Notes 1100

Marketplace > Rensselaer Polytechnic Institute > ComputerScienence > 1100 > RPI Computer Science I Week 1 2 Notes
Chris Fall
View Full Document for 0 Karma

View Full Document


Unlock These Notes for FREE

Enter your email below and we will instantly email you these Notes for Computer Science I

(Limited time offer)

Unlock Notes

Already have a StudySoup account? Login here

Unlock FREE Class Notes

Enter your email below to receive Computer Science I notes

Everyone needs better class notes. Enter your email and we will send you notes for this class for free.

Unlock FREE notes

About this Document

These notes are a synopsis of the material covered in lectures 2-4 of RPI's Computer Science 1 class for the Spring 2016 semester. Hope they're helpful! :D
Computer Science I
Charles Stewart
Class Notes
Computer Science




Popular in Computer Science I

Popular in ComputerScienence

This 7 page Class Notes was uploaded by Chris Fall on Saturday February 6, 2016. The Class Notes belongs to 1100 at Rensselaer Polytechnic Institute taught by Charles Stewart in Spring 2016. Since its upload, it has received 98 views. For similar materials see Computer Science I in ComputerScienence at Rensselaer Polytechnic Institute.


Reviews for RPI Computer Science I Week 1-2 Notes


Report this Material


What is Karma?


Karma is the currency of StudySoup.

You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!

Date Created: 02/06/16
Chris Fall Computer Science I Lecture 2 1. Using Python as an Interactive Calculator  It is possible to type and evaluate basic mathematical expressions directly into the interpreter Ex: 3 * 5= 15 and other similar examples 2. Python Types  A type is a set of possible values (a.k.a. a “representation”), and the set of operations on those values 3. Integers  Includes all whole numbers  The operators on numbers are: +, -, *, /, %, **  All operators work the same as expected except for “/” and “%”  “/” gives the highest possible dividend positively or smallest number negatively (Ex: 29 / 6 = 4, -4 /6 = -1)  “%” gives the remainder (Ex: 29 % 6 = 5)  “**” represents raising a number to a power 4. Float Values  Number with decimal attached(1.5, 3.14159, -7.89)  If result is too large involving numbers, an “overflow error” will occur, meaning there are too many digits for Python to fully process and display 5. Mixing Integers and Floats  To make any integer a float value, simply add a decimal point after it (5.)  When integers and float values are mixed in a computation, everything is converted to float values (when needed- on an operation to operation basis) 6. Variables and Assignment  Python uses a variable system in order to assign numbers to particular variables in memory to make computation easier  These variables can be used with operators just like integers and floats  Must manually set these variables in the interpreter or in code(Ex: pi = 3.14159)  These variables can be individual letters or full words  The equals sign(=) has a different meaning in Python  It essentially means “assign to”  The value of the variable is substituted in for the variable when the variable appears to the right of the =  Values are assigned to the variable when the variable name appears on the left side of the =(the variable will be set to whatever value is present on the right side) 7. Variable Names  Variable names can only start with letters or underscores, and then be followed by any number of letters, underscores, or digits  Cannot contain any spaces, and cannot start with a number  Variable names are case-sensitive(Ex: Rpi is not the same as rpi) 8. Syntax/Semantic Errors  Syntax errors prevent the program from running, whereas semantic errors will allow the program to run, but it will give an output that is not desired or is different from what is expected and/or meant 9. Python Keywords  There are certain words that can’t be used in variable names; these are called keywords  31 of these words exist in this current version of Python  If any of these words are used in or as a variable, the program will return a syntax error 10.Do Variables exist before they are given a value?  No, they must be assigned a value before they are used in any given calculation 11.Expressions  Expressions are legal combinations of values, operators, and variables  They can be as simple as a single value, but the power of Python allows they to be arbitrarily complicated 12.Precedence  The order of operations that are applied is important  The order is: Parentheses, “**” from right to left, Unary + and -, “*” “/” and “%” from left to right, and “+” and “-“ from left to right 13.Mixed Operators  Assignments of the form “i = i + 1” are common in Python, and the program contains shorthand for this type of situation  The shorthand is: i += 1  There are other examples(Ex: -=, *=, both of which carry the same meaning as +=, except with the – sign and * sign respectively) Chris Fall Computer Science I Lecture 3 Notes 1. Definition of a String 1.1.A string is a sequence of 0 or more characters delimited by single or double quotes 1.2.A string must begin and end on the same quotes 1.2.1. For example, “Pie” or ‘Pie’ 1.2.2. If a string like “Pie’ or ‘Pie” is input, Python will return back an end of line syntax error 1.3.If numbers are surrounded in quotes such as in strings, they are treated as strings and not as numbers 1.3.1. Ex: ‘4 8 12 16’ is a string, simply listing 4 8 12 16 keeps the numbers as integers 1.4.An empty string (‘ ‘) is still valid 1.5.Strings, just like integers and floats, can be assigned to variables 1.5.1. Ex: nums = “4 8 12 16” 1.6.Strings are printed differently depending on the commands inputted to print it out 1.6.1. If the command “print” is used, the string returns without any quotes (4 8 12 16) 1.6.2. If the variable name is just typed into the interpreter, the string returns with single quotes (‘4 8 12 16’) 2. Multi-line Strings 2.1.In defining a string in which 3 sets of single or double quotes(“””/ ‘’’) are used, it is possible to type multiple lines within one string 2.2.Until a matching set of 3 single/double quotes are inputted, Python will assume the string is continuing on indefinitely 2.3.Simply typing out the variable associated with the string will print a “\n” between each line while printing the string on the same line 2.3.1. “\n” is a marker that denotes the end of a line, and the creation and start of a new line 3. Escape Characters 3.1.When a back slash is inputted into code, it tells Python that a special character is coming next 3.2.\n has been mentioned 3.3.\t will skip to the next “tab stop” in the text to allow output in columns 3.4.\’ or \” will tell the interpreter to ignore the marking as a string starter or ender and will keep it as normal text within the string 3.5.\\ will indicate that the back slash needs to put in as text instead of denoting an escape character 4. String Operations 4.1.Concatenation 4.1.1. Concatenation takes 2 or more strings and combines them into one string 4.1.2. This is done using the “+” sign Ex: s0 = “Hello” s1 = “World” s0 + s1 = “HelloWorld” Adding strings to this also works(Ex: s0 + ‘ ‘ + s1 = “Hello World”) 4.1.3. Putting multiple strings on the same line comes to the same effect Ex: ‘Good’ ‘Morning’ ‘America’ = ‘GoodMorningAmerica’ 4.1.4. Putting s0 s1 does not work 4.2.Replication 4.2.1. Strings can be replicated using the multiplication operator(*) Ex: s = “Ha” s * 5 = “HaHaHaHaHa” 4.2.2. This can only be done with integers or variables with integers assigned to them, not floats 4.2.3. Multiplying by 0 or a negative number will give an empty string 4.3.Length Function 4.3.1. This determines how long a string is 4.3.2. Denoted by len(string) 4.3.3. When the length is taken, the quotes on the ends do not count towards the length Ex: len(s) = 2 4.3.4. Escape characters only count as 1 characters despite the fact that they contain 2 Ex: len(\n) = 1 4.4.String Function 4.4.1. This function converts other values to strings Ex: str(4.1) = ‘4.1’ 4.5.Float Function 4.5.1. This function converts other values to floats Ex: float(4) = 4.0 4.5.2. The value must be able to convert to a float, therefore trying to convert a string to float will result in a syntax error 5. Formatted Output 5.1.Conversion Specifiers 5.1.1. The percent sign(%) is used to convert values into other types of values within a print statement 5.1.2. To use it, you put a percent sign, followed by a decimal point, then the number of decimal place desired, and lastly the value you want to convert to Ex: %.3f will convert a value to a float with 3 decimal places 5.1.3. At the end of the print statement, you must put a percent sign followed by the variables you want to convert in parentheses Ex: %(area, volume) 5.1.4. %f is for integers, %d is for strings 6. Raw Input Function 6.1.The raw_input function allows Python programs to prompt users for input 6.2.It waits for the user to input something, which is read as a string 6.3.This string can be converted to an integer or float Chris Fall 2/4/16 Comp. Sci. 1 Lecture 4 1. More String Functions 1.1.All of the functions we’ve learned so far have left the original string unchanged 1.2.The “lower” function take a string and converts all of the characters to lowercase 1.2.1. Name = “Chris” Name.lower = “chris” 1.3.The “upper” function converts all characters to uppercase 1.3.1. Name.upper = “CHRIS” 1.4.The “capitalize” function capitalizes the first letter of the string 1.4.1. Name2 = “chris fall” Name2.Capitalize = “Chris fall” 1.5.The “title” function capitalizes the first letter of every word in the string 1.5.1. Name2.title = “Chris Fall” 1.6.The “replace” function will take specified sets of substrings within the string and replaces them with other substrings 1.6.1. Name3 = “Computer Science” Name3.replace(“e”, “f”) = “Computfr Scifncf” 1.7.The “find” function will return back the first occurrence of a specific substring within a string 1.7.1. Each string starts with character number 0(important!) 1.7.2. Name3.find(“e”) = 6 1.7.3. Capital vs. lowercase DOES matter 1.7.4. If the string does not contain that particular substring, the function returns back a -1 1.7.5. Name3.find(“x”) = -1 1.7.6. You can particularly look for the second, or third, any amount of occurrence of a substring in a string by putting the number position you would like to find) Name3.find(“e”, 2”) = 12 1.8.The “count” function returns how many of a particular substring are in a given string 1.8.1. Name3.count(“e”) = 3 1.9.The “strip” function will look for a specific character/substring that the user chooses and will remove any instances of that character/substring that occur on the ends of the string 1.9.1. Name4 = “ 0Cool0” Name4.strip(“0”) = “Cool” 1.9.2. Leaving the parentheses in the strip function blank will remove any spaces on the ends of the string Name5= “ Cool “ Name5.strip() = “Cool” 1.9.3. Escape characters are affected by this function Name6 = “/t Cool” prints “ Cool”, however Name6.strip() = “Cool” 2. Numerical Functions 2.1.The “abs” function takes the absolute value of a number 2.2.The “pow” function takes a number and raises it to a power of the user’s choice 2.3.The “int” function takes a value and converts it to an integer(if possible) 2.4.The “float” function takes a value and converts it to a float value(if possible) 2.5.The “round” function takes a number and rounds it to the nearest whole number 2.6.The “max” function takes a sequence of numbers and returns the largest value 2.7.The “min” function takes a sequence of numbers and returns the smallest value 3. Built__ins function 3.1.By typing in help(__builtins__), Python returns all of the built-in functions that it has to offer and what each function does 4. Objects 4.1.All Python variables are objects 4.2.Each object defines an organization and structure to the data they store 4.3.They have operation/functions- these are called methods- in order to access and manipulate their data 5. Math Database 5.1.By importing the math database(import math), we get access to a whole lot of new commands for things like square roots, powers, and various other numerical processes 6. From command 6.1.Using this command allows the user to only specific commands from a database without importing the entire database 6.2.The command “from math import pi, sqrt” will import only the value of pi and the square root function and nothing else from the math database 7.


Buy Material

Are you sure you want to buy this material for

0 Karma

Buy Material

BOOM! Enjoy Your Free Notes!

We've added these Notes to your profile, click here to view them now.


You're already Subscribed!

Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'

Why people love StudySoup

Steve Martinelli UC Los Angeles

"There's no way I would have passed my Organic Chemistry class this semester without the notes and study guides I got from StudySoup."

Jennifer McGill UCSF Med School

"Selling my MCAT study guides and notes has been a great source of side revenue while I'm in school. Some months I'm making over $500! Plus, it makes me happy knowing that I'm helping future med students with their MCAT."

Bentley McCaw University of Florida

"I was shooting for a perfect 4.0 GPA this semester. Having StudySoup as a study aid was critical to helping me achieve my goal...and I nailed it!"

Parker Thompson 500 Startups

"It's a great way for students to improve their educational experience and it seemed like a product that everybody wants, so all the people participating are winning."

Become an Elite Notetaker and start selling your notes online!

Refund Policy


All subscriptions to StudySoup are paid in full at the time of subscribing. To change your credit card information or to cancel your subscription, go to "Edit Settings". All credit card information will be available there. If you should decide to cancel your subscription, it will continue to be valid until the next payment period, as all payments for the current period were made in advance. For special circumstances, please email


StudySoup has more than 1 million course-specific study resources to help students study smarter. If you’re having trouble finding what you’re looking for, our customer support team can help you find what you need! Feel free to contact them here:

Recurring Subscriptions: If you have canceled your recurring subscription on the day of renewal and have not downloaded any documents, you may request a refund by submitting an email to

Satisfaction Guarantee: If you’re not satisfied with your subscription, you can contact us for further help. Contact must be made within 3 business days of your subscription purchase and your refund request will be subject for review.

Please Note: Refunds can never be provided more than 30 days after the initial purchase date regardless of your activity on the site.