CS 100 Introduction to Computer Science Lab 1 - Playing with Python Due September 21/23, 11:55 PM

Similar documents
University of Hull Department of Computer Science. Wrestling with Python Week 01 Playing with Python

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

CP Lab 2: Writing programs for simple arithmetic problems

CS 1133, LAB 2: FUNCTIONS AND TESTING

Excel Reports and Macros

Chapter 2 Writing Simple Programs

Computer Science 1 CSci 1100 Lecture 3 Python Functions

Installing and Running the Google App Engine On Windows

Lab 2 - CMPS 1043, Computer Science I Introduction to File Input/Output (I/O) Projects and Solutions (C++)

COMSC 100 Programming Exercises, For SP15

Introduction to Python

Computer Programming In QBasic

Exercise 4 Learning Python language fundamentals

Programming in Access VBA

Setting up Python 3.4 and numpy and matplotlib on your own Windows PC or laptop

Exercise 1: Python Language Basics

Notepad++ The COMPSCI 101 Text Editor for Windows. What is a text editor? Install Python 3

Software localisation: Working with PASSOLO

While You Were Sleeping - Scheduling SAS Jobs to Run Automatically Faron Kincheloe, Baylor University, Waco, TX

Welcome to Introduction to programming in Python

Hypercosm. Studio.

Managing Files. On a PC, after you find your file, right click it and selet Rename from the pop-up menu.

Customizing your Blackboard Course

How to use SURA in three simple steps:

While You Were Sleeping - Scheduling SAS Jobs to Run Automatically Faron Kincheloe, Baylor University, Waco, TX

We will learn the Python programming language. Why? Because it is easy to learn and many people write programs in Python so we can share.

Installing C++ compiler for CSc212 Data Structures

CORE K-Nect Web Portal

The Citrix service is now available to faculty and staff at Cypress College.

Using an Automatic Back Up for Outlook 2003 and Outlook 2007 Personal Folders

COMPUTER BASICS. Gordon Kelley Academic Success Center Vines Building, Room

INTRODUCTION TO COMPUTER CONCEPTS CSIT 100 LAB: MICROSOFT POWERPOINT

A Guide to Getting Started with the AmeriCorps VISTA Applicant Tracking Tool

Beginning to Program Python

First Bytes Programming Lab 2

First Certificate in English Online Practice Test Free Sample. How to complete the FCE Online Practice Test Free Sample: Writing

Dwebs IIS Log Archiver Installation and Configuration Guide for Helm 4

Microsoft Outlook. Transition from the ECS Exchange Server to the University Exchange Server. ECS Computing Services August 21, 2012 Version 3.

Vonage Voic Plus. User Guide

Chulalongkorn University International School of Engineering Department of Computer Engineering Computer Programming Lab.

1.1 Installing Protégé You can follow the steps below to download and install Protégé from the source.

Employee Scheduling. Support Guide for Scheduling Employees

Using. An excerpt from Smart Technology's getting started manual explaining the basics of the SmartBoard and how to use it.

Initial Setup of Microsoft Outlook with Google Apps Sync for Windows 7. Initial Setup of Microsoft Outlook with Google Apps Sync for Windows 7

Using Microsoft PowerPoint Software on a SMART Board Interactive Whiteboard

Apple Mac Fundamentals: A Tutorial. Updated 24/4/2013 By Mac Thing enquiries@macthing.co.uk Table of Contents:

MiraCosta College now offers two ways to access your student virtual desktop.

In this lab you will explore the Windows XP Firewall and configure some advanced settings.

SubCue Analyzer Software - Introduction

How To Program An Nxt Mindstorms On A Computer Or Tablet Computer

Outlook Operating Instructions. Internal Desktop Access

File Management Windows

POLARIS INSTALLATION

What is a Mail Merge?

Q: How do I log in to my account?

Visual Basic Programming. An Introduction

Introduction to Python

Send Individually User s Manual

File Management Commands in Windows 7

Restoring your Computer from a Backup in Windows 8 (File History)

Databases in Microsoft Access David M. Marcovitz, Ph.D.

Virtual PBX Planning Instructions

GOALS: The goal for this session is: OBJECTIVES: By the end of the lesson participants should be able to: MATERIALS: Instructor ACTVITIES: EVALUATION:

Lab - Configure a Windows XP Firewall

Using VoiceThread in Your Online Course (Faculty) Step 1: Create a Link for Yourself to Voicethread (1X per course)

Using SSH Secure Shell Client for FTP

How to complete the FCE Online Practice Test Free Sample: Use of English

Grandstream XML Application Guide Three XML Applications

Today s Topics... Intro to Computer Science (cont.) Python exercise. Reading Assignment. Ch 1: 1.5 (through 1.5.2) Lecture Notes CPSC 121 (Fall 2011)

Smart Web. User Guide. Amcom Software, Inc.

Getting Started with Loyola s New Voic System

Using SMART Boards. Display Power (Projector) & PC Buttons on the Console

Managing Documents in the Citrix XenApp Remote Desktop

Graphic Objects and Loading Them into TGF2/MMF2

Verizon Business National Unified Messaging Service Enhanced Service Guide

Lab - Configure a Windows 7 Firewall

Lesson 2. From computer to USB

Using an Android Phone or Tablet For Your Speech / Video Submission Assignment

FREQUENTLY ASKED QUESTIONS ONLINE BANKING

Seagate File Recovery Software for Windows - User Guide August 2015

Employee Online. Contents. Logging in to Employee Online

Approving timesheets via SPIRIT Online Supervisors of hourly employees

Intellect Platform - The Workflow Engine Basic HelpDesk Troubleticket System - A102

Introduction to Python

Accessing vlabs using the VMware Horizon View Client for OSX

Optional Lab: Schedule Task Using GUI and at Command in Windows 7

Creating a Mira filing account in Mozilla Thunderbird 1.x. Open Thunderbird In the Tools menu, choose Accounts settings

How to complete the FCE Online Practice Test Free Sample: Reading

Mini School Application Package for 2016

Online Vaccine Ordering & Management Tools. NYC Department of Health & Mental Hygiene Bureau of Immunization

Enhancing Lectures with an Audience Response System: Workshop Guide

AccessLine Smart 800 User Guide

Using Remote Desktop with the Cisco AnyConnect VPN Client in Windows Vista

r-one Python Setup 1 Setup 2 Using IDLE 3 Using IDLE with your Robot ENGI 128: Introduction to Engineering Systems Fall, 2014

Dynamics CRM for Outlook Basics

Lab 9. Spam, Spam, Spam. Handout 11 CSCI 134: Spring, To gain experience with Strings. Objective

Organizational Development Qualtrics Online Surveys for Program Evaluation

Transcription:

CS 100 Introduction to Computer Science Lab 1 - Playing with Python Due September 21/23, 11:55 PM First, a word about due dates. If you are in the Tuesday lab section, your assignment is due Monday night at 11:55 PM. If you are in the Thursday lab section, your assignment is due Wednesday night at 11:55 PM. Second, we have 3 TAs for this class. They will be available in the Kendade lab. They will create a list on the whiteboard. If you need help, you should add your name to the list so that they can talk with you in order. Here is when they are available: Xuefei Chen Hilary Ming Turner Wiley Sunday 7-9 PM Monday 7-9 PM Wednesday 7-9 PM Now, the good stuff. In this class, we will be programming in Python, using a special environment called JES (Jython Environment for Students). Connecting to your MHC file space You should first connect to your MHC file space. To do that, please follow the instructions at https://www.mtholyoke.edu/lits/tech/map_metwork_drives_windowspc When entering the Folder, use the path for your personal file storage, which is: \\mhc\yourusename It is very important that you disconnect your network drive before you leave the lab. To do this, right-click on the computer icon and select the disconnect command. After connecting to your web space, create a folder named cs100. You should put all of your work for this class in this folder. Let s put each week s assignments in a separate folder. So, create a folder named Lab1 inside your cs100 folder. You will save the files that you write this week in that folder.!1

Exploring JES To start JES, click on the Windows icon in the bottom-left corner of the screen. Click on All Programs and scroll to the JES folder. Click on the JES folder and you should see the JES program with a green python head for an icon. Click that file to start JES. A splash screen will appear for a while and then you should see Part 1: Using the command area The command area is the black area at the bottom of the window. Here, you can type commands and get immediate answers. For example, you can use it like a calculator. (10 points) Use the command area to answer these questions. Place your answers in a file called Lab1_yourname and submit that file on Moodle. 1. What does 2 / 3 evaluate to? What does 2.0 / 3 evaluate to? Why are these different? 2. What does 2 + 3 evaluate to? What does + mean when working with numbers? What does Hi + there evaluate to? What does + mean for strings? 3. What does 2 * 3 evaluate to? What does * mean when working with numbers? What does Hi * 3 evaluate to? What does * mean for strings? 4. What does 100 * 3 evaluate to? What does 100 * 3 evaluate to? Why are these different?!2

5. Give the value 2015 to the name year, like >>> year = 2015 Do something similar for birthyear, but giving it the value of the year you were born. Now calculate your age (or the age you will be by Dec. 31 2015, actually) by saying >>> year - birthyear Explain why the expression above gives the answer that you get. Try the functions we created in class Go to the lecture page of the course web site (https://www.mtholyoke.edu/~blerner/cs100/ schedule.html) and download the examples from September 15. In JES, open the File menu and select Open Program Navigate to the file you just downloaded and open it. The file is called Lecture02.py. This should display the functions we created in class with a lot of comments (the lines beginning with #) explaining the functions and how to use them. Click the Load Program button. JES now understands all of these functions and you can use them. 1. Run the hello function from the command area by typing hello () (without the quotes). It should display Hello, world! below the line you typed. 2. Now, try the pickandshow function. 3. Next, edit the showmypicture function so that it includes the name of an image file on your computer. Read the comment above showmypicture to learn how to find the name of a file. Do you understand why this function behaves differently than pickandshow? 4. Now, call showpicture. Notice that this time, you need to pass the filename as a parameter. Make sure you understand why. (20 points) Part 2: Write your own functions To write your own functions, open the File menu and select New Program. At the top of the file, put a comment (a line beginning with #) that includes your name, identifies the lab and whether you are in the Tuesday or Wednesday lab section, like this: # Barbara Lerner, CS 100 Lab 1, Wednesday lab section Save all the functions that you define here in a file called Lab1.py and turn it in on Moodle. 1. Type in this function that prints the result of squaring a number: def square(x): print x * x Now in the command area at the bottom, call the square function with each of these arguments: 3, 3.3, Hello. Record the responses in the doc file you created earlier. (Remember to click Load Program again.)!3

2. Write a function called fahrenheittocelsius. To convert from Fahrenheit to Celsius, you need to subtract 32 from the Fahrenheit temperature and then multiply the result by 5/9. 3. Write a function called feettoyards. The function should take in some number of feet and tell you the number of yards. Make sure the result uses floating point, not integer representation. (For those of you who only know (the more sensible) metric system, there are 3 feet in 1 yard.) 4. Write a function called sayhello. The function should take a name as a parameter and greet the caller by name. For example, sayhello( Mary Lyon ) might print out What s up, Mary Lyon? sayhello( Tom Brady ) would print What s up, Tom Brady?. You should not need to change your function to get different output, only how you call the function in the command area. (10 points) Part 3: Understanding error messages One thing that makes programming hard, is that computers are very picky about exactly how you say something. They are really not very smart!. You need to remember where all the punctuation goes, and to indent the statements inside a function. Python really cares about this! You also need to remember the names of the functions you can use, type them correctly(!), and what the parameters are. For these questions, you will deliberately introduce mistakes in your program. I want you to record what error message you see. Sometimes the same error message may indicate different problems, but it is still a good idea to get used to the error messages and what they mean. I want you to turn in a record of these observations, but also keep a copy for yourself that you can refer to in future labs. For each of these, make the change I suggest, record the error message. Then fix it before going on to the next item in the list. Add the answers to these to the file you created in the first part of the lab where you explored the command area. First, make a copy of the pickandshow function from Lecture03.py in another file. We will introduce errors into it and we do not want to modify the original version! 1. Erase the : at the end of the def line. Load the program. 2. Indent the lines of the function so that it looks like this: def pickandshow () : myfile = pickafile() mypict = makepicture(myfile) show(mypict) 3. Change mypict to mypic (remove the t) in the call to the show function on line 4. You should see no errors when you load the program. Now call pickandshow() in the command area. What happens? 4. Replace mypict with 100 in the call to show. Load the program and then call pickand- Show(). 5. Remove the parameter mypict when you call show. Load the program and then call pickandshow().!4

Turning in your answers Please submit your answers on Moodle. You should submit 2 files - Lab1.py containing your answers to Part 2 and a text/word/pdf file containing the answers to parts 1 and 3. Remember to disconnect your network drive so nobody else can see your files! To do this, right-click on the computer icon and select the disconnect command.!5