CS Lab 8. Part 1 - Basics of File I/O

Size: px
Start display at page:

Download "CS Lab 8. Part 1 - Basics of File I/O"

Transcription

1 CS Lab 8 Today, you will be doing a lot with files! We will start with the basics of reading and writing and then expand upon the pixel value work that you did in a previous lab by working on image processing with ASCII art. Let's get to it with the basics of file I/O. I recommend that you try out Spyder instead of IDLE for today s work. On your USB drive or account, create a new folder called lab08, and put all of today s work in it. Files to download from the class Web site: alice.txt, input.txt, image.bmp Periodically during the lab, please have one of us check your progress. Have fun! Part 1 - Basics of File I/O Open up Spyder and create a new file. Enter the following code and save the file as file_writing.py. Finally, run the code from the Run menu. file = open('myfile.txt', 'w') file.write('hello, world!') file.close() What happened when you ran this script? Create a new file in the same directory called file_reading.py and put the following text in it: file = open('myfile.txt', 'r') text = file.read() print(text) file.close() What happens now? Try opening myfile.txt in a text editor and changing its contents. Does this change the output of the program? What do you think the 'r' and 'w' arguments mean in the open function? Let's try opening a file that doesn't exist. Modify file_reading.py to open nonexist.txt instead of myfile.txt and now run it again. You should get an error:

2 FileNotFoundError: [Errno 2] No such file or directory: 'nonexist.txt' You cannot open files for reading when they don't exist. When writing a new file, the file will be created if it doesn't exist, or overwritten if it does exist. To fix this problem, it is good practice to check whether a file exists before trying to open it. Luckily for us, Python has a way of doing this already using the os.path module. Modify file_reading.py to read like this: import os.path if os.path.isfile('nonexist.txt'): file = open('nonexist.txt', 'r') text = file.read() print(text) file.close() else: print("this file cannot be found!") Now, when you run the file, you gracefully recover from errors (meaning your program deals with problems and doesn't just crash when something goes wrong). This will help you with the next part of the lab, in which we create a simple program to remember certain things about the user. Run file_reading.py again to verify this, show your professor or aide, and move onto part 3 when finished! Part 2 - Remember Me! Now it's time to put your file skills to the test. Create a new program called remember_me.py which does the following: If the file user.txt exists: Open the file and store its contents in a variable called name. (hint: file_reading.py shows you how) Close the file. Ask the user if their name is what was stored in the text file. If so, greet them by name. print('hi there,' + name + '!') If not, ask the user to input a new name and save it in user.txt for next time.* End the program. Otherwise: Ask the user for their name and put it into a variable.* Create a new file called user.txt and put the name into this file.* Close the file.* *Note: these steps appear whether or not the user.txt file exists. Instead of typing them twice, consider combining them into a subroutine. def make_new_user() could be the name for your subroutine. Here's some skeleton code to get you started: # remember_me.py # This program will store some information about the last person who used it # into a text file, and will greet the user when they next log in. # Imports import os.path # Functions and Subroutines def make_new_user(): # Greet the user and ask for their name and age

3 # Open up a text file (called user.txt) in write mode. # Write the name to the file # Close the file # MAIN PROGRAM: # If no file exists, then nobody has used the program before. # Greet the user and make a new text file. if not os.path.isfile('user.txt'): make_new_user() else: # Open up the user's file in read mode and load his/her name # Read everything from the file into a string # Close the file # Ask if this is the correct user # Greet the user if they chose yes. If not, make_new_user(). Complete the code and make sure that it runs correctly, then move onto Part 3. Part 3 - ASCII Art! Now that you have a good understanding of file I/O, we're going to look at something entirely different: text art! In your last lab, you read in pixel values that you used to determine whether a certain value was light or dark. In this new lab, you will be converting each pixel from a bitmap file to a Unicode character. Viewed from a distance, this will appear as art! The following is an example of the output from the finished program: A brief introduction to Unicode Unicode is a universal character encoding system that supersedes older encoding standards such as ASCII. Most languages can be represented in Unicode. Python 3 uses Unicode as its standard encoding language. Let's try converting between regular text and Unicode. The ord() function will convert a single character to its

4 Unicode equivalent. Go to the Spyder shell and type the following: >>> ord('a') >>> ord('b') >>> ord('c') >>> ord('a') >>> ord('b') >>> ord('c') What are the numbers you get back? Use the ord() function as above to get the Unicode equivalent for your first name. Write in the values here. The following is a copy of the complete ASCII table.

5 Convert your first name into ASCII using the table above and write them down. Use the 'Chr' and 'Dec' values. Compare this sequence to the one you got in the previous question. Notice how the Unicode and ASCII values are identical for letters. Why do you think this might be? ASCII Blocks Now, let's get into the art! The main idea is that we're going to take a pixel and convert it to one of a few possible characters. These characters are: Nearest color Character Python Character Code White ' ' Light '\u2591' Medium '\u2592' Dark '\u2593' Black '\u2588' You can see these codes in action by typing print('\u2591') and the like into a shell. Let's make the program now. We're going to be using bitmap image files and the Python Imaging Library (PIL) to do the hard work of reading bitmap files pixel by pixel. Each pixel will consist of a tuple of (red,green,blue) values. You are going to be averaging these together and coming up with a single value, the lightness of the pixel. Depending on the lightness, you will either output black, dark, medium, light, or white Unicode blocks. First, download an image that is less than 64 pixels wide and 40 pixels tall. You can find a few on the class website or you can search for one on Google Images. You can even make one in Microsoft Paint. Save this image as a bitmap and call it image.bmp Create a new file called text_art.py and put the following into it. Be absolutely sure you are using a bitmap. The Python Imaging Library won't work on these computers with any other image types. # Imports from PIL import Image # Declarations white = ' ' light = '\u2591' medium = '\u2592' dark = '\u2593' black = '\u2588' # Open image

6 im = Image.open('image.bmp') # file name can be changed to whatever you use. im = im.convert('rgb') width, height = im.size # Convert the image for i in range(height): for j in range(width): # Get all three values (red, green, and blue) r, g, b = im.getpixel((j,i)) # Calculate the average of r, g, and b as an integer average = # Decide which text character to print. # average will be a value from 0 to 255 if <= average <= : print(black, end='') # Black elif <= average <= : print(dark, end='') # Dark Gray elif <= average <= : print(medium, end='') # Medium Gray elif <= average <= : print(light, end='') # Light Gray else: print(white, end='') # White # Finish off the line print() Replace the blanks ( ) with code. For the average line, use a formula or a built-in function. For the if statements, use numbers. Run your program and observe the output. Modify it until your ranges choose the characters that most resemble the light values in your image. Which ranges did you finally decide on? Write them in the blanks above as well as your average function. Show your professor or aide when finished! Part 4 Next, you will write a couple of Python programs that will practice steganography. This means we are going to hide a secret message inside an otherwise innocent looking text file. Here are the steps to follow. Open your folder lab08. From the class Web site, please download a large input file called input.txt and another called alice.txt. The first one is a famous speech given by President Reagan in 1987 in Berlin. We want to write two programs: Let's write steg.py. This program will hide a short secret message, among the characters of the speech (input.txt), and it will write the resulting output to a new file, output.txt. This program will have the following structure. Create a variable called secretmessage, and set it equal to some sentence of your choice. Open the input and output files, and associate each one with a variable. Read the entire input file into a string variable. For example, the name of this string variable could be text.

7 Write a loop that examines each character in the string. The loop needs to be written in such a way that the variable i refers to which letter in the string we are looking at. For example, i = 0 is the first character, i = 1 is the next character, and so on. In other words, all letters in the input file are numbered, all the way up to the total number of bytes in the file, which in this case is about 15,000. The purpose of the loop is to copy the input file into the output file. But we have to hide our secret message. How? Let's say that every 100th character of the input file is going to be replaced with the next character of the secret message. Let me show you how this is done: if i % 100 == 0 and i /100 < len(secretmessage): outfile.write(secretmessage[int(i/100)]) else: outfile.write(text[i]) At the end of the program, tell Python to close the files. Run the program steg.py and look at the output.txt file. Can you tell if anything has changed relative to the input.txt file? If so, what is different? Let s write steg2.py: This program will attempt to discover the hidden message that is contained inside output.txt. The program will print the secret message to the screen. In other words, steg2.py only needs to open 1 file. At the beginning of the program, create an empty string called secretmessage. This is where we are going to store the message that was left for us in output.txt. This program will have the same general structure as steg.py. But the idea here is that on every 100th character of the text, the program needs to grab this character and place it in our secretmessage. For instance, try this if-statement inside your loop that looks at every character in the text: if i % 100 == 0: secretmessage += text[i] Finally, at the end of the program, print the secretmessage to the screen. Run steg2.py. Is the secret message being printed out correctly? Why is the program printing more text than the length of this message? Changing every 100th character in the input file is not stealthy. It s especially obvious to a casual reader if there is an alteration very early in the text file, such as in the first few words. It s also better to hide our message inside a larger body of text. How about a whole book?

8 Copy steg.py and steg2.py into new files steg3.py and steg4.py, respectively. Change steg3.py so that the input file is alice.txt instead of input.txt. The output file should be alice_output.txt instead of output.txt. Modify steg3.py and steg4.py so that they do not change letters so often. Instead, let s change every 1,000th character. Also, if we write a condition that says that we are going to modify a character if i % 1000 == 0, this statement is true when i is zero. This means we will be changing the first letter in the text file. Does this sound like a good idea? Why / why not? Instead, let s arrange for the program to change the following characters. Pick some number from , say 687 (not zero or a very small number). In this case, we ll change the 687th character; and then every 1000th character after that. In other words, we want to ask if the remainder of dividing i by 1000 is 687, rather than zero. Modify steg3.py and steg4.py accordingly, and verify that the secret message is preserved. You should look at output.txt to see that it s a little more difficult to find letters of your secret message. Where are its first three letters? Experiment with a third input file. Especially a file that is large and already has a lot of typos or other weird looking text in it. Also use a different secret message and a different formula for placing characters in the output file. Create complementary programs steg5.py and steg6.py (analogous to our original steg.py and steg2.py) to do the encoding and decoding, respectively. Be stealthy! That's it! Have the professor or aide check your work and you can leave.

Hello World! Computer Programming for Kids and Other Beginners. Chapter 1. by Warren Sande and Carter Sande. Copyright 2009 Manning Publications

Hello World! Computer Programming for Kids and Other Beginners. Chapter 1. by Warren Sande and Carter Sande. Copyright 2009 Manning Publications Hello World! Computer Programming for Kids and Other Beginners by Warren Sande and Carter Sande Chapter 1 Copyright 2009 Manning Publications brief contents Preface xiii Acknowledgments xix About this

More information

You just told Matlab to create two strings of letters 'I have no idea what I m doing' and to name those strings str1 and str2.

You just told Matlab to create two strings of letters 'I have no idea what I m doing' and to name those strings str1 and str2. Chapter 2: Strings and Vectors str1 = 'this is all new to me' str2='i have no clue what I am doing' str1 = this is all new to me str2 = I have no clue what I am doing You just told Matlab to create two

More information

All textures produced with Texture Maker. Not Applicable. Beginner.

All textures produced with Texture Maker. Not Applicable. Beginner. Tutorial for Texture Maker 2.8 or above. Note:- Texture Maker is a texture creation tool by Tobias Reichert. For further product information please visit the official site at http://www.texturemaker.com

More information

Draw beautiful and intricate patterns with Python Turtle, while learning how to code with Python.

Draw beautiful and intricate patterns with Python Turtle, while learning how to code with Python. Raspberry Pi Learning Resources Turtle Snowflakes Draw beautiful and intricate patterns with Python Turtle, while learning how to code with Python. How to draw with Python Turtle 1. To begin, you will

More information

Introduction to JES and Programming. Installation

Introduction to JES and Programming. Installation Introduction to JES and Programming Installation Installing JES and starting it up Windows users: Just copy the folder Double-click JES application Mac users: Just copy the folder Double-click the JES

More information

Lesson 18: Animation. Computer Programming is Fun!

Lesson 18: Animation. Computer Programming is Fun! Lesson 18: Animation So how do you make your drawings move and change? That's what this section is about. I'd like to introduce you to your new friend, Mr. Timer. A timer gives you the ability to tell

More information

CS Problem Solving and Object-Oriented Programming

CS Problem Solving and Object-Oriented Programming CS 101 - Problem Solving and Object-Oriented Programming Lab 5 - Draw a Penguin Due: October 28/29 Pre-lab Preparation Before coming to lab, you are expected to have: Read Bruce chapters 1-3 Introduction

More information

Getting Started. Excerpted from Hello World! Computer Programming for Kids and Other Beginners

Getting Started. Excerpted from Hello World! Computer Programming for Kids and Other Beginners Getting Started Excerpted from Hello World! Computer Programming for Kids and Other Beginners EARLY ACCESS EDITION Warren D. Sande and Carter Sande MEAP Release: May 2008 Softbound print: November 2008

More information

Honors Computer Science Python Mr. Clausen Program 7A, 7B

Honors Computer Science Python Mr. Clausen Program 7A, 7B Honors Computer Science Python Mr. Clausen Program 7A, 7B PROGRAM 7A Turtle Graphics Animation (100 points) Here is the overview of the program. Use functions to draw a minimum of two background scenes.

More information

Physics REU Unix Tutorial

Physics REU Unix Tutorial Physics REU Unix Tutorial What is unix? Unix is an operating system. In simple terms, its the set of programs that makes a computer work. It can be broken down into three parts. (1) kernel: The component

More information

Directory of C:\Users\Ami\Documents\Python Scripts

Directory of C:\Users\Ami\Documents\Python Scripts Chapter 8: Files and I/O Up to this point, all input and output has taken place using the keyboard and the command console. Specifically, the function input() has been used to collect user data, and the

More information

Lesson 4: Who Goes There?

Lesson 4: Who Goes There? Lesson 4: Who Goes There? In this lesson we will write a program that asks for your name and a password, and prints a secret message if you give the right password. While doing this we will learn: 1. What

More information

Introduction to Programming with JES

Introduction to Programming with JES Introduction to Programming with JES Titus Winters & Josef Spjut October 6, 2005 1 Introduction First off, welcome to UCR, and congratulations on becoming a Computer Engineering major. Excellent choice.

More information

Functional Programming in Haskell Prof. Madhavan Mukund and S. P. Suresh Chennai Mathematical Institute

Functional Programming in Haskell Prof. Madhavan Mukund and S. P. Suresh Chennai Mathematical Institute Functional Programming in Haskell Prof. Madhavan Mukund and S. P. Suresh Chennai Mathematical Institute Module # 02 Lecture - 03 Characters and Strings So, let us turn our attention to a data type we have

More information

Arduino 05: Digital I/O. Jeffrey A. Meunier University of Connecticut

Arduino 05: Digital I/O. Jeffrey A. Meunier University of Connecticut Arduino 05: Digital I/O Jeffrey A. Meunier jeffm@engr.uconn.edu University of Connecticut About: How to use this document I designed this tutorial to be tall and narrow so that you can read it on one side

More information

Android Programming Family Fun Day using AppInventor

Android Programming Family Fun Day using AppInventor Android Programming Family Fun Day using AppInventor Table of Contents A step-by-step guide to making a simple app...2 Getting your app running on the emulator...9 Getting your app onto your phone or tablet...10

More information

CS Lab 11. Today's Objectives. Prime Number Generation Implement Diffie-Hellman Key Exchange Implement RSA Encryption

CS Lab 11. Today's Objectives. Prime Number Generation Implement Diffie-Hellman Key Exchange Implement RSA Encryption CS 105 - Lab 11 Today's Objectives Prime Number Generation Implement Dfie-Hellman Key Exchange Implement RSA Encryption Part 1: Dfie-Hellman Key Exchange In class you learned about the Dfie-Hellman-Merkle

More information

There are two ways to use the python interpreter: interactive mode and script mode. (a) open a terminal shell (terminal emulator in Applications Menu)

There are two ways to use the python interpreter: interactive mode and script mode. (a) open a terminal shell (terminal emulator in Applications Menu) I. INTERACTIVE MODE VERSUS SCRIPT MODE There are two ways to use the python interpreter: interactive mode and script mode. 1. Interactive Mode (a) open a terminal shell (terminal emulator in Applications

More information

CONTENTS: What Is Programming? How a Computer Works Programming Languages Java Basics. COMP-202 Unit 1: Introduction

CONTENTS: What Is Programming? How a Computer Works Programming Languages Java Basics. COMP-202 Unit 1: Introduction CONTENTS: What Is Programming? How a Computer Works Programming Languages Java Basics COMP-202 Unit 1: Introduction Announcements Did you miss the first lecture? Come talk to me after class. If you want

More information

CSI Lab 02. Tuesday, January 21st

CSI Lab 02. Tuesday, January 21st CSI Lab 02 Tuesday, January 21st Objectives: Explore some basic functionality of python Introduction Last week we talked about the fact that a computer is, among other things, a tool to perform high speed

More information

What we already know. more of what we know. results, searching for "This" 6/21/2017. chapter 14

What we already know. more of what we know. results, searching for This 6/21/2017. chapter 14 What we already know chapter 14 Files and Exceptions II Files are bytes on disk. Two types, text and binary (we are working with text) open creates a connection between the disk contents and the program

More information

Transcription of The Magic Picture" Lesson

Transcription of The Magic Picture Lesson First Segment: Transcription of The Magic Picture" Lesson Once upon a time, a woman came to a ruler and said," I complain to you that I do not have mice at my place!" People around the ruler started wondering,

More information

PYTHON YEAR 10 RESOURCE. Practical 01: Printing to the Shell KS3. Integrated Development Environment

PYTHON YEAR 10 RESOURCE. Practical 01: Printing to the Shell KS3. Integrated Development Environment Practical 01: Printing to the Shell To program in Python you need the latest version of Python, which is freely available at www.python.org. Your school will have this installed on the computers for you,

More information

CISC 1600 Lecture 3.1 Introduction to Processing

CISC 1600 Lecture 3.1 Introduction to Processing CISC 1600 Lecture 3.1 Introduction to Processing Topics: Example sketches Drawing functions in Processing Colors in Processing General Processing syntax Processing is for sketching Designed to allow artists

More information

Flying Start AS Computer Science. September 2015

Flying Start AS Computer Science. September 2015 Flying Start AS Computer Science September 2015 Name: To your first AS Computing lesson, you will need to bring: 1. A folder with dividers An A4 ring binder with labelled A4 dividers would be ideal. The

More information

CS 105 Lab As a review of what we did last week a. What are two ways in which the Python shell is useful to us?

CS 105 Lab As a review of what we did last week a. What are two ways in which the Python shell is useful to us? 1 CS 105 Lab 3 The purpose of this lab is to practice the techniques of making choices and looping. Before you begin, please be sure that you understand the following concepts that we went over in class:

More information

ECS Baruch Lab 3 Spring 2019 Name

ECS Baruch Lab 3 Spring 2019 Name ECS 102 - Baruch Lab 3 Spring 2019 Name I. You can't ask a computer to do something you can't do. Now it is your turn to step through a program, without a computer. DO NOT ENTER THIS PROGRAM ON THE COMPUTER.

More information

An Introduction to Python

An Introduction to Python An Introduction to Python Getting Started 1 of 30 January 4, 2017 What You Need to Get Started? Python An object-oriented language gaining popularity in the industry IPython An interactive version of Python

More information

CS101 Lecture 24: Thinking in Python: Input and Output Variables and Arithmetic. Aaron Stevens 28 March Overview/Questions

CS101 Lecture 24: Thinking in Python: Input and Output Variables and Arithmetic. Aaron Stevens 28 March Overview/Questions CS101 Lecture 24: Thinking in Python: Input and Output Variables and Arithmetic Aaron Stevens 28 March 2011 1 Overview/Questions Review: Programmability Why learn programming? What is a programming language?

More information

Introduction to: Computers & Programming: Strings and Other Sequences

Introduction to: Computers & Programming: Strings and Other Sequences Introduction to: Computers & Programming: Strings and Other Sequences in Python Part I Adam Meyers New York University Outline What is a Data Structure? What is a Sequence? Sequences in Python All About

More information

Problem 1. Remove consecutive duplicates (6 points, 11 mintues)

Problem 1. Remove consecutive duplicates (6 points, 11 mintues) Problem 1. Remove consecutive duplicates (6 points, 11 mintues) CS3 Fall 04 Midterm 2 Consider a function remove-conseq-dups that takes a sentence and returns a sentence in which any occurrences of a word

More information

Research Question: Do people perform better on a math task after observing Impressionist art or modern art?

Research Question: Do people perform better on a math task after observing Impressionist art or modern art? MEDIA LAB TUTORIAL Research Question: Do people perform better on a math task after observing Impressionist art or modern art? All of the graphics you will use should be stored in a folder that you will

More information

Arduino IDE Friday, 26 October 2018

Arduino IDE Friday, 26 October 2018 Arduino IDE Friday, 26 October 2018 12:38 PM Looking Under The Hood Of The Arduino IDE FIND THE ARDUINO IDE DOWNLOAD First, jump on the internet with your favorite browser, and navigate to www.arduino.cc.

More information

CS 1301 Exam 2 Fall 2013

CS 1301 Exam 2 Fall 2013 CS 1301 Exam 2 Fall 2013 Name : Section TA: Integrity: By taking this exam, you pledge that this is your work and you have neither given nor received inappropriate help during the taking of this exam in

More information

Lesson 1. Importing and Organizing Footage using Premiere Pro CS3- CS5

Lesson 1. Importing and Organizing Footage using Premiere Pro CS3- CS5 Lesson 1 Importing and Organizing Footage using Premiere Pro CS3- CS5 When working with a video editor the video source will come from either a capturing process or importing video clips into the editing

More information

Using IDLE for

Using IDLE for Using IDLE for 15-110 Step 1: Installing Python Download and install Python using the Resources page of the 15-110 website. Be sure to install version 3.3.2 and the correct version depending on whether

More information

Introduction to: Computers & Programming: Strings and Other Sequences

Introduction to: Computers & Programming: Strings and Other Sequences Introduction to: Computers & Programming: Strings and Other Sequences in Python Part I Adam Meyers New York University Outline What is a Data Structure? What is a Sequence? Sequences in Python All About

More information

Long Filename Specification

Long Filename Specification Long Filename Specification by vindaci fourth release First Release: November 18th, 1996 Last Update: January 6th, 1998 (Document readability update) Compatibility Long filename (here on forth referred

More information

CMSC 201 Spring 2019 Lab 06 Lists

CMSC 201 Spring 2019 Lab 06 Lists CMSC 201 Spring 2019 Lab 06 Lists Assignment: Lab 06 Lists Due Date: Thursday, March 7th by 11:59:59 PM Value: 10 points This week s lab will put into practice the concepts you learned about lists: indexing,

More information

MITOCW watch?v=rvrkt-jxvko

MITOCW watch?v=rvrkt-jxvko MITOCW watch?v=rvrkt-jxvko The following content is provided under a Creative Commons license. Your support will help MIT OpenCourseWare continue to offer high quality educational resources for free. To

More information

Introduction to Scratch

Introduction to Scratch Introduction to Scratch Familiarising yourself with Scratch The Stage Sprites Scripts Area Sequence of Instructions Instructions and Controls If a computer is a box think of a program as a man inside the

More information

What's the Slope of a Line?

What's the Slope of a Line? What's the Slope of a Line? These lines look pretty different, don't they? Lines are used to keep track of lots of info -- like how much money a company makes. Just off the top of your head, which of the

More information

How to Make a Book Interior File

How to Make a Book Interior File How to Make a Book Interior File These instructions are for paperbacks or ebooks that are supposed to be a duplicate of paperback copies. (Note: This is not for getting a document ready for Kindle or for

More information

CS 1110, LAB 3: MODULES AND TESTING First Name: Last Name: NetID:

CS 1110, LAB 3: MODULES AND TESTING   First Name: Last Name: NetID: CS 1110, LAB 3: MODULES AND TESTING http://www.cs.cornell.edu/courses/cs11102013fa/labs/lab03.pdf First Name: Last Name: NetID: The purpose of this lab is to help you better understand functions, and to

More information

Sequence of Characters. Non-printing Characters. And Then There Is """ """ Subset of UTF-8. String Representation 6/5/2018.

Sequence of Characters. Non-printing Characters. And Then There Is   Subset of UTF-8. String Representation 6/5/2018. Chapter 4 Working with Strings Sequence of Characters we've talked about strings being a sequence of characters. a string is indicated between ' ' or " " the exact sequence of characters is maintained

More information

Girls Programming Network. Sassy Security Chatbots! Extensions!

Girls Programming Network. Sassy Security Chatbots! Extensions! Girls Programming Network 2017 Sassy Security Chatbots! Extensions! Extension Time! Now that we have our sassy security chatbot running, it s time to add more features! You can complete the extensions

More information

CS 1301 Exam 1 Fall 2010

CS 1301 Exam 1 Fall 2010 CS 1301 Exam 1 Fall 2010 Name : Grading TA: Integrity: By taking this exam, you pledge that this is your work and you have neither given nor received inappropriate help during the taking of this exam in

More information

Assignment 0. Nothing here to hand in

Assignment 0. Nothing here to hand in Assignment 0 Nothing here to hand in The questions here have solutions attached. Follow the solutions to see what to do, if you cannot otherwise guess. Though there is nothing here to hand in, it is very

More information

Intro to Programming. Unit 7. What is Programming? What is Programming? Intro to Programming

Intro to Programming. Unit 7. What is Programming? What is Programming? Intro to Programming Intro to Programming Unit 7 Intro to Programming 1 What is Programming? 1. Programming Languages 2. Markup vs. Programming 1. Introduction 2. Print Statement 3. Strings 4. Types and Values 5. Math Externals

More information

Ascii Art. CS 1301 Individual Homework 7 Ascii Art Due: Monday April 4 th, before 11:55pm Out of 100 points

Ascii Art. CS 1301 Individual Homework 7 Ascii Art Due: Monday April 4 th, before 11:55pm Out of 100 points CS 1301 Individual Homework 7 Ascii Art Due: Monday April 4 th, before 11:55pm Out of 100 points Files to submit: 1. HW7.py THIS IS AN INDIVIDUAL ASSIGNMENT! You should work individually on this assignment.

More information

CS354 gdb Tutorial Written by Chris Feilbach

CS354 gdb Tutorial Written by Chris Feilbach CS354 gdb Tutorial Written by Chris Feilbach Purpose This tutorial aims to show you the basics of using gdb to debug C programs. gdb is the GNU debugger, and is provided on systems that

More information

The inverse of a matrix

The inverse of a matrix The inverse of a matrix A matrix that has an inverse is called invertible. A matrix that does not have an inverse is called singular. Most matrices don't have an inverse. The only kind of matrix that has

More information

Starting. Read: Chapter 1, Appendix B from textbook.

Starting. Read: Chapter 1, Appendix B from textbook. Read: Chapter 1, Appendix B from textbook. Starting There are two ways to run your Python program using the interpreter 1 : from the command line or by using IDLE (which also comes with a text editor;

More information

MITOCW watch?v=flgjisf3l78

MITOCW watch?v=flgjisf3l78 MITOCW watch?v=flgjisf3l78 The following content is provided under a Creative Commons license. Your support will help MIT OpenCourseWare continue to offer high-quality educational resources for free. To

More information

Spring CS Homework 3 p. 1. CS Homework 3

Spring CS Homework 3 p. 1. CS Homework 3 Spring 2018 - CS 111 - Homework 3 p. 1 Deadline 11:59 pm on Friday, February 9, 2018 Purpose CS 111 - Homework 3 To try out another testing function, check-within, to get more practice using the design

More information

Lesson 3 Transcript: Part 1 of 2 - Tools & Scripting

Lesson 3 Transcript: Part 1 of 2 - Tools & Scripting Lesson 3 Transcript: Part 1 of 2 - Tools & Scripting Slide 1: Cover Welcome to lesson 3 of the db2 on Campus lecture series. Today we're going to talk about tools and scripting, and this is part 1 of 2

More information

I put a shortcut onto your desktop, the screen that you look at after you log in.

I put a shortcut onto your desktop, the screen that you look at after you log in. In this lesson, you ll learn to create your first program. I put a shortcut onto your desktop, the screen that you look at after you log in. When you double-click on this shortcut, a folder will open.

More information

BASIC COMPUTATION. public static void main(string [] args) Fundamentals of Computer Science I

BASIC COMPUTATION. public static void main(string [] args) Fundamentals of Computer Science I BASIC COMPUTATION x public static void main(string [] args) Fundamentals of Computer Science I Outline Using Eclipse Data Types Variables Primitive and Class Data Types Expressions Declaration Assignment

More information

Blackfin Online Learning & Development

Blackfin Online Learning & Development Presentation Title: Multimedia Starter Kit Presenter Name: George Stephan Chapter 1: Introduction Sub-chapter 1a: Overview Chapter 2: Blackfin Starter Kits Sub-chapter 2a: What is a Starter Kit? Sub-chapter

More information

CS390 Principles of Concurrency and Parallelism. Lecture Notes for Lecture #5 2/2/2012. Author: Jared Hall

CS390 Principles of Concurrency and Parallelism. Lecture Notes for Lecture #5 2/2/2012. Author: Jared Hall CS390 Principles of Concurrency and Parallelism Lecture Notes for Lecture #5 2/2/2012 Author: Jared Hall This lecture was the introduction the the programming language: Erlang. It is important to understand

More information

CpSc 101, Fall 2015 Lab7: Image File Creation

CpSc 101, Fall 2015 Lab7: Image File Creation CpSc 101, Fall 2015 Lab7: Image File Creation Goals Construct a C language program that will produce images of the flags of Poland, Netherland, and Italy. Image files Images (e.g. digital photos) consist

More information

CSCI 1100L: Topics in Computing Lab Lab 11: Programming with Scratch

CSCI 1100L: Topics in Computing Lab Lab 11: Programming with Scratch CSCI 1100L: Topics in Computing Lab Lab 11: Programming with Scratch Purpose: We will take a look at programming this week using a language called Scratch. Scratch is a programming language that was developed

More information

Due: 9 February 2017 at 1159pm (2359, Pacific Standard Time)

Due: 9 February 2017 at 1159pm (2359, Pacific Standard Time) CSE 11 Winter 2017 Program Assignment #2 (100 points) START EARLY! Due: 9 February 2017 at 1159pm (2359, Pacific Standard Time) PROGRAM #2: DoubleArray11 READ THE ENTIRE ASSIGNMENT BEFORE STARTING In lecture,

More information

MITOCW watch?v=kz7jjltq9r4

MITOCW watch?v=kz7jjltq9r4 MITOCW watch?v=kz7jjltq9r4 PROFESSOR: We're going to look at the most fundamental of all mathematical data types, namely sets, and let's begin with the definitions. So informally, a set is a collection

More information

Depending on the computer you find yourself in front of, here s what you ll need to do to open SPSS.

Depending on the computer you find yourself in front of, here s what you ll need to do to open SPSS. 1 SPSS 11.5 for Windows Introductory Assignment Material covered: Opening an existing SPSS data file, creating new data files, generating frequency distributions and descriptive statistics, obtaining printouts

More information

CS 100 Python commands, computing concepts, and algorithmic approaches for final Fall 2015

CS 100 Python commands, computing concepts, and algorithmic approaches for final Fall 2015 CS 100 Python commands, computing concepts, and algorithmic approaches for final Fall 2015 These pages will NOT BE INCLUDED IN THE MIDTERM. print - Displays a value in the command area - Examples: - print

More information

6.S189 Homework 1. What to turn in. Exercise 1.1 Installing Python. Exercise 1.2 Hello, world!

6.S189 Homework 1. What to turn in. Exercise 1.1 Installing Python. Exercise 1.2 Hello, world! 6.S189 Homework 1 http://web.mit.edu/6.189/www/materials.html What to turn in Do the warm-up problems for Days 1 & 2 on the online tutor. Complete the problems below on your computer and get a checkoff

More information

CMSC 201 Spring 2016 Lab 08 Strings and File I/O

CMSC 201 Spring 2016 Lab 08 Strings and File I/O CMSC 201 Spring 2016 Lab 08 Strings and File I/O Assignment: Lab 08 Strings and File I/O Due Date: During discussion, April 4 th through April 7 th Value: 10 points Part 1: File Input Using files as input

More information

1 of 11. TUTORIAL - Content Creator Plus (CCP) (for Trainz 2006) Written Aug. 21, By Jytte Christrup. HOW TO MAKE A SOUND FILE, Step by Step

1 of 11. TUTORIAL - Content Creator Plus (CCP) (for Trainz 2006) Written Aug. 21, By Jytte Christrup. HOW TO MAKE A SOUND FILE, Step by Step 1 of 11 TUTORIAL - Content Creator Plus (CCP) (for Trainz 2006) Written Aug. 21, 2008. By Jytte Christrup. HOW TO MAKE A SOUND FILE, Step by Step Before you get started, you will need 5 files: - the wav

More information

CS 2505 Computer Organization I Test 1

CS 2505 Computer Organization I Test 1 Instructions: Print your name in the space provided below. This examination is closed book and closed notes, aside from the permitted one-page formula sheet. No calculators or other computing devices may

More information

Tutorial: GNU Radio Companion

Tutorial: GNU Radio Companion Tutorials» Guided Tutorials» Previous: Introduction Next: Programming GNU Radio in Python Tutorial: GNU Radio Companion Objectives Create flowgraphs using the standard block libraries Learn how to debug

More information

Project 3: RPN Calculator

Project 3: RPN Calculator ECE267 @ UIC, Spring 2012, Wenjing Rao Project 3: RPN Calculator What to do: Ask the user to input a string of expression in RPN form (+ - * / ), use a stack to evaluate the result and display the result

More information

Scientific Programming Algolab. Wednesday 21 Dec 2016

Scientific Programming Algolab. Wednesday 21 Dec 2016 Algolab (index.html#chapters) Out[1]: Exam Simulation Exam Simulation Scientific Programming Algolab Wednesday 21 Dec 2016 Introduction This is just an exam simulation. If you don't ship it or do a poor

More information

CS 463 Project 1 Imperative/OOP Fractals

CS 463 Project 1 Imperative/OOP Fractals CS 463 Project 1 Imperative/OOP Fractals The goal of a couple of our projects is to compare a simple project across different programming paradigms. This semester, we will calculate the Mandelbrot Set

More information

Excel Basics Rice Digital Media Commons Guide Written for Microsoft Excel 2010 Windows Edition by Eric Miller

Excel Basics Rice Digital Media Commons Guide Written for Microsoft Excel 2010 Windows Edition by Eric Miller Excel Basics Rice Digital Media Commons Guide Written for Microsoft Excel 2010 Windows Edition by Eric Miller Table of Contents Introduction!... 1 Part 1: Entering Data!... 2 1.a: Typing!... 2 1.b: Editing

More information

Step-by. A Very Warm Welcome to the Exciting World of Computers. Let s get Started It s easy with my Step- Instructions

Step-by. A Very Warm Welcome to the Exciting World of Computers. Let s get Started It s easy with my Step- Instructions A Very Warm Welcome to the Exciting World of Computers Let s get Started It s easy with my Step- by-step Instructions This lesson is all about getting to know your Main Menu Bar at the top of your screen.

More information

Python 2. KS3 Programming Workbook. Name. ICT Teacher Form. Taking you Parseltongue further. Created by D.Aldred P a g e 1

Python 2. KS3 Programming Workbook. Name. ICT Teacher Form. Taking you Parseltongue further. Created by D.Aldred P a g e 1 Python 2 KS3 Programming Workbook Taking you Parseltongue further Name ICT Teacher Form Created by D.Aldred P a g e 1 To Execute the program code press F5 Welcome to Python The python software has two

More information

15-110: Principles of Computing, Spring 2018

15-110: Principles of Computing, Spring 2018 15-110: Principles of Computing, Spring 2018 Programming Assignment 11 (PA11) Due: Tuesday, May 1 by 9PM IMPORTANT ANNOUNCEMENT You cant drop this assignment even if it is your lowest PA score. Failure

More information

A PROGRAM IS A SEQUENCE of instructions that a computer can execute to

A PROGRAM IS A SEQUENCE of instructions that a computer can execute to A PROGRAM IS A SEQUENCE of instructions that a computer can execute to perform some task. A simple enough idea, but for the computer to make any use of the instructions, they must be written in a form

More information

Everything you always wanted to know about Fonts*

Everything you always wanted to know about Fonts* Everything you always wanted to know about Fonts* (*but were afraid to ask) or.. "Using Mac fonts in the Avid Media Composer" The font system in the Mac isn't necessarily the easiest thing to understand.

More information

15-110: Principles of Computing Sample Exam #1

15-110: Principles of Computing Sample Exam #1 15-110: Principles of Computing Sample Exam #1 The following is a "sample exam" that you can use to practice after you have studied for the exam. Keep in mind that the actual exam will have its own questions,

More information

CS 112 Project Assignment: Visual Password

CS 112 Project Assignment: Visual Password CS 112 Project Assignment: Visual Password Instructor: Dan Fleck Overview In this project you will use Python to implement a visual password system. In the industry today there is ongoing research about

More information

Strings in Python: Cipher Applications CS 8: Introduction to Computer Science, Winter 2018 Lecture #9

Strings in Python: Cipher Applications CS 8: Introduction to Computer Science, Winter 2018 Lecture #9 Strings in Python: Cipher Applications CS 8: Introduction to Computer Science, Winter 2018 Lecture #9 Ziad Matni Dept. of Computer Science, UCSB Administrative Homework #4 is due today Homework #5 is out

More information

CS 1301 Exam 1 Fall 2010

CS 1301 Exam 1 Fall 2010 CS 1301 Exam 1 Fall 2010 Name : Grading TA: Integrity: By taking this exam, you pledge that this is your work and you have neither given nor received inappropriate help during the taking of this exam in

More information

CSC 101: Lab Manual#11 Programming Turtle Graphics in Python Lab due date: 5:00pm, day after lab session

CSC 101: Lab Manual#11 Programming Turtle Graphics in Python Lab due date: 5:00pm, day after lab session CSC 101: Lab Manual#11 Programming Turtle Graphics in Python Lab due date: 5:00pm, day after lab session Purpose: The purpose of this lab is to get a little introduction to the process of computer programming

More information

CS Programming Exercise:

CS Programming Exercise: CS Programming Exercise: An Introduction to Java and the ObjectDraw Library Objective: To demonstrate the use of objectdraw graphics primitives and Java programming tools This lab will introduce you to

More information

Text Input and Conditionals

Text Input and Conditionals Text Input and Conditionals Text Input Many programs allow the user to enter information, like a username and password. Python makes taking input from the user seamless with a single line of code: input()

More information

CMPSCI 119 LAB #2 Greebles / Anime Eyes Professor William T. Verts

CMPSCI 119 LAB #2 Greebles / Anime Eyes Professor William T. Verts CMPSCI 119 LAB #2 Greebles / Anime Eyes Professor William T. Verts The goal of this Python programming assignment is to write your own code inside a provided program framework, with some new graphical

More information

Direct Variations DIRECT AND INVERSE VARIATIONS 19. Name

Direct Variations DIRECT AND INVERSE VARIATIONS 19. Name DIRECT AND INVERSE VARIATIONS 19 Direct Variations Name Of the many relationships that two variables can have, one category is called a direct variation. Use the description and example of direct variation

More information

Arduino 6: Analog I/O part 1. Jeffrey A. Meunier University of Connecticut

Arduino 6: Analog I/O part 1. Jeffrey A. Meunier University of Connecticut Arduino 6: Analog I/O part 1 Jeffrey A. Meunier jeffm@engr.uconn.edu University of Connecticut About: How to use this document I designed this tutorial to be tall and narrow so that you can read it on

More information

Article Buddy User Manual

Article Buddy User Manual Article Buddy User Manual Hello and thank you for buying Article Buddy. This guide right here focuses on the features of this absolutely amazing software and how to use it to its fullest. How Do You Use

More information

4. Java Project Design, Input Methods

4. Java Project Design, Input Methods 4-1 4. Java Project Design, Input Methods Review and Preview You should now be fairly comfortable with creating, compiling and running simple Java projects. In this class, we continue learning new Java

More information

Design and Analysis of Algorithms Prof. Madhavan Mukund Chennai Mathematical Institute. Module 02 Lecture - 45 Memoization

Design and Analysis of Algorithms Prof. Madhavan Mukund Chennai Mathematical Institute. Module 02 Lecture - 45 Memoization Design and Analysis of Algorithms Prof. Madhavan Mukund Chennai Mathematical Institute Module 02 Lecture - 45 Memoization Let us continue our discussion of inductive definitions. (Refer Slide Time: 00:05)

More information

[ the academy_of_code] Senior Beginners

[ the academy_of_code] Senior Beginners [ the academy_of_code] Senior Beginners 1 Drawing Circles First step open Processing Open Processing by clicking on the Processing icon (that s the white P on the blue background your teacher will tell

More information

Arduino 02: Using the Arduino with Python. Jeffrey A. Meunier University of Connecticut

Arduino 02: Using the Arduino with Python. Jeffrey A. Meunier University of Connecticut Arduino 02: Using the Arduino with Python Jeffrey A. Meunier jeffm@engr.uconn.edu University of Connecticut About: How to use this document I designed this tutorial to be tall and narrow so that you can

More information

Why You Should Not Use Arch

Why You Should Not Use Arch Why You Should Not Use Arch A new users guide to highly personalized, low maintenance operating system. Artur Frącek CC BY-NC-ND 4.0 1 Intro Arch is a very good Linux distribution so it is not a surprise

More information

Welcome Back! Without further delay, let s get started! First Things First. If you haven t done it already, download Turbo Lister from ebay.

Welcome Back! Without further delay, let s get started! First Things First. If you haven t done it already, download Turbo Lister from ebay. Welcome Back! Now that we ve covered the basics on how to use templates and how to customise them, it s time to learn some more advanced techniques that will help you create outstanding ebay listings!

More information

CS 101 Representing Information. Lecture 5

CS 101 Representing Information. Lecture 5 CS 101 Representing Information Lecture 5 1 Representing Information Computers are capable of storing, transmitting, and displaying information For example, Text files, Word documents, JPEG videos, MOV

More information

CS Homework 11 p. 1. CS Homework 11

CS Homework 11 p. 1. CS Homework 11 CS 111 - Homework 11 p. 1 Deadline 11:59 pm on Monday, May 2, 2016 How to submit Each time you would like to submit your work: CS 111 - Homework 11 If your files are not already on nrs-labs, be sure to

More information

Working with Strings. Husni. "The Practice of Computing Using Python", Punch & Enbody, Copyright 2013 Pearson Education, Inc.

Working with Strings. Husni. The Practice of Computing Using Python, Punch & Enbody, Copyright 2013 Pearson Education, Inc. Working with Strings Husni "The Practice of Computing Using Python", Punch & Enbody, Copyright 2013 Pearson Education, Inc. Sequence of characters We've talked about strings being a sequence of characters.

More information