ECS Baruch Lab 5 Spring 2019 Name NetID (login, like , not your SUID)

Similar documents
ECS Baruch Lab 9 Spring 2019 Name

ECS Baruch Lab 3 Spring 2019 Name

CSC 120 Computer Science for the Sciences. Week 1 Lecture 2. UofT St. George January 11, 2016

CS 1110, LAB 2: FUNCTIONS AND ASSIGNMENTS

(Type your answer in radians. Round to the nearest hundredth as needed.)

Com S 127 Lab 2. For the first two parts of the lab, start up Wing 101 and use the Python shell window to try everything out.

ECS Baruch Lab 2 Fall 2019 Name

Lecture 3. Functions & Modules

CS 102 Lab 3 Fall 2012

Week 3: Objects, Input and Processing

Lecture 7. Memory in Python

Lecture 3. Functions & Modules

Downloaded from Chapter 2. Functions

CS 1110, LAB 2: ASSIGNMENTS AND STRINGS

Customer details are included on a separate worksheet (Customer Look Up) Item details are included on a separate worksheet (Item Look Up)

Elementary Statistics. Organizing Raw Data

An Introduction to Python for KS4!

CS110: PROGRAMMING LANGUAGE I

cs1114 REVIEW of details test closed laptop period

Trigonometric Functions of Any Angle

Math 26: Fall (part 1) The Unit Circle: Cosine and Sine (Evaluating Cosine and Sine, and The Pythagorean Identity)

static int min(int a, int b) Returns the smaller of two int values. static double pow(double a,

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

The Math Class (Outsource: Math Class Supplement) Random Numbers. Lab 06 Math Class

CSE 115. Introduction to Computer Science I

SAMS Programming A/B. Lecture #1 Introductions July 3, Mark Stehlik

ENCM 339 Fall 2017 Lecture Section 01 Lab 9 for the Week of November 20

Resize and Watermark Images Using Ribbet.com

Hands-on Session. Styles Tool. Bullets & Numbering

ECS Baruch Lab 12 Spring 2019 Name

Lecture 3: Functions & Modules

Math 144 Activity #3 Coterminal Angles and Reference Angles

CSI31 Lecture 5. Topics: 3.1 Numeric Data Types 3.2 Using the Math Library 3.3 Accumulating Results: Factorial

USER MANUAL. Contents. Analytic Reporting Tool Basic for SUITECRM

Lecture 1. Course Overview Types & Expressions

Math 144 Activity #4 Connecting the unit circle to the graphs of the trig functions

Lab 1 RVIZ and PYTHON with Simple Robot Manipulator Model

Interactive Tourist Map

CS-184: Computer Graphics. Today. 2D Scan Conversion. Tuesday, October 7, Drawing Lines Drawing Curves Filled Polygons Filling Algorithms

Unit R Student Success Sheet (SSS) Trigonometric Identities Part 2 (section 5.4)

ECE 3793 Matlab Project 1

CS-184: Computer Graphics

CS 150 Lab 3 Arithmetic and the Debugger. Lab 3.0 We are going to begin using the Visual Studio 2017 debugger to aid with debugging programs.

CS 1110 Prelim 1 October 17th, 2013

Candy is Dandy Project (Project #12)

Adding an Open HMIS Release of Information (ROI) (updated 4/26/18)

2.) Open you re my documents folder, and then open you re my pictures folder. Now create a new folder called mask advert.

Excel Spreadsheets and Graphs

CMPSCI 119 Spring 2015 Final Exam Friday, May 1, 2015 Solution Key

Functions with Parameters and Return Values

Lesson 4 Customize the ToolBox

SIIT ITS 323. Due Friday 21 August 2007, 5pm 10% of the final course mark

CS-184: Computer Graphics. Today

Getting Started. Chapter 1. How to Get Matlab. 1.1 Before We Begin Matlab to Accompany Lay s Linear Algebra Text

Problem 1: Binary, Decimal, and Hex Number Representations [6 marks]

Name: Partners: Math Academy I. Review 5 Version A

TerminalFOUR Version 8 Change Guide

CSCI 136 Programming Exam #2 Fundamentals of Computer Science II Spring 2012

Lecture 3. Strings, Functions, & Modules

Excel Basics Fall 2016

Programming. We will be introducing various new elements of Python and using them to solve increasingly interesting and complex problems.

MET 107 Drawing Tool (Shapes) Notes Day 3

Pre-Lab Excel Problem

Math Lab 6: Powerful Fun with Power Series Representations of Functions Due noon Thu. Jan. 11 in class *note new due time, location for winter quarter

How To Think Like A Computer Scientist, chapter 3; chapter 6, sections

ECE 463 Lab 1: Introduction to LabVIEW

Copied from: on 3/20/2017

1. Make a bar graph in Excel. (1.5 points) Copy the following table into two columns under a blank worksheet in Excel.

You ll use the six trigonometric functions of an angle to do this. In some cases, you will be able to use properties of the = 46

Assignment 3: Due Thursday Feb 26 at 11pm

My Reviewers User Manual Series

Exam 1 Format, Concepts, What you should be able to do, and Sample Problems

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

MATH EXAM 1 - SPRING 2018 SOLUTION

User Guide for Applicants PROJECT. DATE & VERSION 11 th Oct 2016, Version: 2.0. Scholarships Management System Applicant Portal

Proficiency Testing Program Data Reporting Website Instruction Manual

My Assignments. Quick Start Guide

LAB 2: DATA FILTERING AND NOISE REDUCTION

Part 1 Your First Function

Microsoft Excel Microsoft Excel

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

Finding Pi: Applications of Loops, Random Numbers, Booleans CS 8: Introduction to Computer Science, Winter 2018 Lecture #6

Trigonometry Review Version 0.1 (September 6, 2004)

Introduction to Programming

AP Calculus Summer Review Packet

Unit 7: Algorithms and Python CS 101, Fall 2018

MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.

Python Lists: Example 1: >>> items=["apple", "orange",100,25.5] >>> items[0] 'apple' >>> 3*items[:2]

University of Pennsylvania. Department of Electrical and Systems Engineering. ESE Undergraduate Laboratory. Introduction to LabView

CS 1110 SPRING 2016: GETTING STARTED (Jan 27-28) First Name: Last Name: NetID:

Introduction to Programming

Chapter 8G - Law of Sines and Law of Cosines

Introduction to Computer Programming in Python Dr. William C. Bulko. Data Types

MINT Interactive User s Guide

Introduction to Python. Genome 559: Introduction to Statistical and Computational Genomics Prof. James H. Thomas

Introduction to Programming

To create a notebook on desktop version 1. Open One Note 2. File > New. o FILE. Options

PREPARING FOR PRELIM 1

SUM AND DIFFERENCES. Section 5.3 Precalculus PreAP/Dual, Revised 2017

The float type and more on variables FEB 6 TH 2012

Transcription:

ECS 102 - Baruch Lab 5 Spring 2019 Name NetID (login, like email, not your SUID) Today you will be doing some more experiments in the shell. Create a file Lab5.txt. In this file you will be asked to save parts of the shell (just copy and paste). Don't copy all your experiments, just the final good ones. I. Exploring built in Functions. You may use IDLE or Thonny today. Write your name and "Part I" in the file Lab5.txt There are some functions built into Python itself. Try these: A. >>> x=4.7 >>>y=2 >>>print(type(x)) >>>print(type(y)) B. >>>a = int(x) >>>print("a=",a,"\tx=",x) The \t represents a tab character. >>>b = float(y) >>>print("b=",b,"\ny=",y) The \n represents a new line character. Were the values stored in x and y changed? (You don't need to debug, you can look at the output.) C. >>>r=8.9 >>>round(r) >>>s=6.5 >>>round(s) 1

>>>t=1.4999 >>>round(t) >>> print("r=",r,"\ts=",s, "\tt=",t) Were the values stored in r, s, and t changed? Copy the shell for part I to Lab5.txt. (Save!) II. Using math functions. Restart the shell. Write "Part II" in the file Lab5.txt In the class notes for today is a list of built in math functions. You will need to import math to use them. >>> import math A. Try >>> sin(90) What happens? The problem is that to use the math functions, we need to put math. in front of them. Try >>> math.sin(90) >>> math.cos(90) Does it look like Python is using degrees for sin and cos? Try >>>math.pi Result to 5 decimal places: >>>math.sin(math.pi/2) >>>math.cos(math.pi/2) Does it look like Python is using radians for sin and cos? 2

B. Write a few lines of code that will print a table of sines and cosines, from 0 degrees to 180 degrees (inclusive) in steps of 10 degrees. You will need to use the formula onedegreeinradians= math.pi/180, so to compute sin(10 degrees) you will need to compute sin(10*onedegreeinradians). Make sure your table has the right number of rows. Don't worry if the columns don't line up nicely. Just make sure there are three columns, for degrees, sin, and cos. Looking at the output. Does the table give exactly 1 for cos(0)? exactly 0 for sin(0)? Does the table give exactly 0 for cos(90 degrees)? exactly 1 for sin(90 degree)? Does the table give exactly -1 for cos(180 degrees)? exactly 0 for sin(180 degrees)? Make a guess about why you got some "no"s for you answers above and write it here. Copy the shell for your good solution of II B with the output table, to part II of Lab5.txt. (Save!) Print Lab5.txt III. More loops, accumulating a product. A. In addition to accumulating a sum as we did in Lab 4, sometimes we want to accumulate a product. For example 7! = 1 * 2 * 3 * 4 * 5 * 6 * 7. We can compute this in a loop, by each time multiplying the product by one more number. To start out our process, the product has to be initialized to 1, not zero. Why? Write a program, in a module file Lab5PartIII.py, with a main() and a call to main(), to compute 10! Save the program. Run the program. What does it get for 10!?: B. ints and floats Modify the program to compute 10! and 10.0! using ints (1*2*3...) and floats(1.0*2.0*3.0...) Print both results. Are the int and float results the same? Save your program. 3

C. 100! Modify your program to ask the user for an int value k. It should then compute k!, both the int and the float versions. (Use float for each term in the computation, not just for the final result.) Run the program, entering the value 10, and check that you get the same results as for part B. Now run the program and enter 100, for 100!. Are the int and float results exactly the same as each other? Are they close? Save your program. Save a copy as Lab5partIII.txt and copy your good output (that is, the computed values of 10! and 100!) to the same textfile, at the bottom, labeled "output". Make sure your name is at the top of the file. Print the text file, and close Lab5partIII.py. IV. Introduction to graphics. A. To do graphics you will need to download the graphics.py file and put it in your Python Programs folder. (This is where you should be saving all you programs.) This is the link, http://mcsp.wartburg.edu/zelle/python/ but it is also on the lecture page. B. While you are at that site you should download the Graphics Resource pdf file, too. Put it in a good place on your H: drive - you will want to refer to it often. C. From our course lecture webpage, download the file FourCorners.py. From the shell open that file. Put your name and section at the top, where indicated in the comment. Save the file. We will be adding to this during lab. D. Run the program. You should see a window with a circle, like this here: Click the mouse in the window to close the window. i) Look at the code creating the window. How many pixels wide is the window? How many pixels tall is the window? 4

ii) On this picture, write coordinates for the four corners of the windows. For example, label the upper left corner (0,0). (Make use of your answer to part i) iii) Give the coordinates for the center of the green circle. (Look at the code for the circle.) Write the coordinates on the picture above, on the green circle. iv) I want to draw 3 more circles, in the other 4 corners, a bit in from the corners just as the green circle is. On the paper picture, label where the centers should be, by writing the coordinates at those points. v) Create and draw the other 3 circles. vi) Color the upper left circle yellow, the lower right circle red, and the lower left circle blue. Run the program and make sure the window with the picture stays open till you click the mouse in the window. Print FourCorners.py by making a.txt file and printing that. Take a screen shot of your graphics window, Four Corners, with all 4 circles. V. Submitting your work. Make sure your name is on this lab packet. Staple Lab5.txt Lab5partIII.txt and Four Corners.txt to the Lab 5 packet. Turn the lab in at the file cabinet. Upload the screenshot of the graphics window Four Corners using the link on today's lecture page. 5