Assignment 1: Due Friday Feb 6 at 6pm

Similar documents
1. The two triangles shown below are similar. This means that all the angles are equal and the sides are proportional.

CS1112 Fall 2009 Project 2. Objectives. 1 Stirling. due Thursday 9/24 at 11pm

COMS 6100 Class Notes

Lab Exercise 6 CS 2334

Investigation: Transit Tracks

Assignment 1. Due Feb. 11, 2019

Numbers. The aim of this lesson is to enable you to: describe and use the number system. use positive and negative numbers

Date: Problem Set # 1. Unit conversion is an important part of any scientific research. Please view the following link: c = (gh) α (3)

Scientific Notation and Scaled Models

PTOLEMY DAY 6 THE SEXAGESIMAL SYSTEM AND THE NEED FOR A TABLE OF CHORDS AND ARCS

Math 3361-Modern Algebra Lecture 08 9/26/ Cardinality

Transit Tracks. Activity G14. What s This Activity About? Tips and Suggestions. What Will Students Do? What Will Students Learn?

The Science of Astronomy - Copernicus, Tycho, and Kepler. Reminder to take out your clicker and turn it on!

APS 1030 Astronomy Lab 79 Kepler's Laws KEPLER'S LAWS

6. How Functions Work and Are Accessed. Topics: Modules and Functions More on Importing Call Frames

Tycho Brahe and Johannes Kepler

Manipulating Radicals

Learning Outcomes in Focus

How Do You Group It?

ASTR 4 Solar System Astronom y

18 An Eclipsing Extrasolar Planet

Introduction. PTYS/ASTR 206 The Golden Age of Planetary Exploration Shane Byrne

Astron 104 Laboratory #5 The Size of the Solar System

AST101: Our Corner of the Universe Lab 5: Solar System Models

CS1110 Lab 3 (Feb 10-11, 2015)

On my honor, as an Aggie, I have neither given nor received unauthorized aid on this academic work

Argyle Magnet Middle School Summer Math Packet ANSWERS

Completing this project will help you learn about two-dimensional arrays, structures, and structure arrays. More on Matlab graphics and GUI design.

Pre-Algebra Notes Integer Exponents and Scientific Notation

Yes, inner planets tend to be and outer planets tend to be.

A Note on Turing Machine Design

EXPERIMENT MEASUREMENT

Lab 1. Moon Phases: Why Does the Appearance of the Moon Change Over Time in a Predictable Pattern?

8 th Grade Intensive Math

Math 138: Introduction to solving systems of equations with matrices. The Concept of Balance for Systems of Equations

USING THE EXCEL CHART WIZARD TO CREATE CURVE FITS (DATA ANALYSIS).

At the end of the exam you must copy that folder onto a USB stick. Also, you must your files to the instructor.

How big is the Universe and where are we in it?

Astronomy 104: Stellar Astronomy

Physics Unit 7: Circular Motion, Universal Gravitation, and Satellite Orbits. Planetary Motion

Readings and Exercises

ASTRO 1050 LAB #1: Scientific Notation, Scale Models, and Calculations

Notater: INF3331. Veronika Heimsbakk December 4, Introduction 3

Math 3000 Section 003 Intro to Abstract Math Homework 6

Patterns in the Solar System (Chapter 18)

Unit 3 NOTES Honors Common Core Math 2 1. Day 1: Properties of Exponents

Investigating the Solar System

4Roots and Powers BUILDING ON BIG IDEAS NEW VOCABULARY

Turing Machines Part Two

Relative Photometry with data from the Peter van de Kamp Observatory D. Cohen and E. Jensen (v.1.0 October 19, 2014)

Developed and Published by. AIMS Education Foundation

5 + 9(10) + 3(100) + 0(1000) + 2(10000) =

Astronomy. (rěv ə-lōō shən)) The Copernican Revolution. Phys There are problems with the Ptolemaic Model. Problems with Ptolemy

Communication Engineering Prof. Surendra Prasad Department of Electrical Engineering Indian Institute of Technology, Delhi

Introduction to Computer Programming, Spring Term 2018 Practice Assignment 1 Discussion:

Math 31 Lesson Plan. Day 5: Intro to Groups. Elizabeth Gillaspy. September 28, 2011

Math 31 Lesson Plan. Day 2: Sets; Binary Operations. Elizabeth Gillaspy. September 23, 2011

GEOLOGY ON MARS Unit 1 - Chapter 1-1

GEOL212 Due 9/24/18 Homework 4

Binary addition (1-bit) P Q Y = P + Q Comments Carry = Carry = Carry = Carry = 1 P Q

CS173 Lecture B, November 3, 2015

MEP Practice Book ES1. (h) (l) Simplify each of the following, leaving your answer in index notation.

Traditional Mathematics in the Aomori Prefecture

STARTING WITH CONFIDENCE

October 19, NOTES Solar System Data Table.notebook. Which page in the ESRT???? million km million. average.

Lab 5 The Green House Effect Pre-lab

Measuring Keepers S E S S I O N 1. 5 A

KNOWLEDGE TO GET FROM TODAY S CLASS MEETING

IN THE ALMIGHTY GOD NAME Through the Mother of God mediation I do this research

COMP 120. For any doubts in the following, contact Agam, Room. 023

: Intro Programming for Scientists and Engineers Assignment 4: Learning from Echocardiograms

Lab 2 Worksheet. Problems. Problem 1: Geometry and Linear Equations

Finding a Percent of a Number (page 216)

Unit 2: Exponents and Radicals

Summative Assessment #2 for Outer Space and Cyber Space

Physics 2020 Laboratory Manual

Checkpoint Questions Due Monday, October 1 at 2:15 PM Remaining Questions Due Friday, October 5 at 2:15 PM

Math Topic: Unit Conversions and Statistical Analysis of Data with Categorical and Quantitative Graphs

GE 226 Introduction to Experimental Labs. Stan Shadick, Lab Co-ordinator

Edexcel AS and A Level Mathematics Year 1/AS - Pure Mathematics

UNIT 14 Exponents. Scientific Notation

Measurement Year 9. The topic Measurement includes units because any size has no meaning without the units. Every answer must include the units used.

Calculus II. Calculus II tends to be a very difficult course for many students. There are many reasons for this.

Planet Scaling using Extra Terrestrial Tools

Gravitation & Kepler s Laws

Planet Club. Version AUG-2005

Measurement Year 10. The topic Measurement includes units because any size has no meaning without the units. Every answer must include the units used.

Adam Blank Spring 2017 CSE 311. Foundations of Computing I. * All slides are a combined effort between previous instructors of the course

LETTER TO FAMILY. Science News. Cut here and paste onto school letterhead before making copies. Dear Family,

Extended Introduction to Computer Science CS1001.py. Lecture 8 part A: Finding Zeroes of Real Functions: Newton Raphson Iteration

1 THE SOLAR SYSTEM. six

Experiment 2. Reaction Time. Make a series of measurements of your reaction time. Use statistics to analyze your reaction time.

Announcements Wednesday, August 30

You should have finished reading Chapter 3, and started on chapter 4 for next week.

Unit: Planetary Science

Parity Checker Example. EECS150 - Digital Design Lecture 9 - Finite State Machines 1. Formal Design Process. Formal Design Process

EXAM #2. ANSWERS ASTR , Spring 2008

CS Analysis of Recursive Algorithms and Brute Force

of Nebraska - Lincoln

Exercise 4.0 PLANETARY ORBITS AND CONFIGURATIONS

Transcription:

CS1110 Spring 2015 Assignment 1: Due Friday Feb 6 at 6pm You must work either on your own or with one partner. If you work with a partner, you and your partner must first register as a group in CMS and then submit your work as a group. You may discuss background issues and general solution strategies with others, but the programs you submit must be the work of just you (and your partner). We assume that you are thoroughly familiar with the discussion of academic integrity that is on the course website. Any doubts that you have about crossing the line should be discussed with a member of the teaching staff before the deadline. Objectives. Mastering the assignment statement and conditional execution. Practicing with strings and string slicing. Using print, str, int, len, import and raw input. You will get experience bridging the gap from math formula to Python code. You will get practice processing strings according to given rules. Finally, your ability to manipulate files and directories and the Komodo editor will be enhanced. The assignment is based on Lectures 1,2, and 3 and Labs 1 and 2. 1 Music of the Spheres There are five Platonic solids: The tetrahedron has 4 faces, the cube has 6 faces the octahedron has 8 faces, the dodecahedron has 12 faces, and the icosahedron has 20 faces. All the edges of a Platonic solid have the same length. Platonic solids have many interesting properties. Here are a couple that relate to the cube: 1. If the edge of a cube has length, then the radius of the largest sphere that can be put inside is given by r /2. 2. If the edge of a cube has length, then the radius of the smallest sphere that encloses the cube is given by R ( 3/2). We say that r is the inradius of a cube with edge and that R is its outradius. Here is table of inradii and outradii for each the Platonic solid: Solid r R Tetrahedron with edge 6 12 6 4 Cube with edge 1 2 3 2 Octahedron with edge Dodecahedron with edge Icosahedron with edge 1 6 250 + 110 5 20 3 3 + 15 12 1 2 15 + 3 4 10 + 2 5 4

Thus, the radius of the largest sphere that can be placed inside an octahedron with edge is given by r / 6. The facts in the table can be used to investigate an interesting idea that the astronomer/astrologer Kepler had about planetary orbits. Consider the following Platonic Nesting procedure: Start with a sphere S 1 with radius 1. (ρ 1 1) Let O be the smallest octahedron that encloses S 1. Let S 2 be the smallest sphere that encloses O. Call its radius ρ 2. Let I be the smallest icosahedron that encloses S 2. Let S 3 be the smallest sphere that encloses I. Call its radius ρ 3. Let D be the smallest dodecahedron that encloses S 3. Let S 4 be the smallest sphere that encloses D. Call its radius ρ 4. Let T be the smallest tetrahedron that encloses S 4. Let S 5 be the smallest sphere that encloses T. Call its radius ρ 5. Let C be the smallest cube that encloses S 5. Let S 6 be the smallest sphere that encloses C. Call its radius ρ 6. Kepler s music of the spheres conjecture is that ρ 2 ρ 1 Venus Orbit Radius Mercury Orbit Radius ρ 3 ρ 2 arth Orbit Radius Venus Orbit Radius ρ 4 ρ 3 Mars Orbit Radius arth Orbit Radius ρ 5 ρ 4 Jupiter Orbit Radius Mars Orbit Radius ρ 6 ρ 5 Saturn Orbit Radius Jupiter Orbit Radius In other words, the spheres that arise in the Platonic nesting could be used to predict the spacing of the planets. Below are schematics from the 1500s that depict the nesting. On the left you can see the Saturn, Jupiter, and Mars spheres, i.e., S 6, S 5, and S 4. The right schematic is on a much smaller scale, but the Mars, arth, Venus, and Mercury spheres are in there, i.e., S 4, S 3 S 2, and S 1. Music of the Spheres

In this problem you write a Python script Kepler.py that checks out Kepler s conjecture. The entries in the inradius/outradius table can be used to compute the sphere radii ρ 2, ρ 3, ρ 4, ρ 5, and ρ 6. For example, Q: What is the smallest cube that encloses a sphere of radius ρ 5? A: Using the cube inradius formula we conclude that the cube will have edge 2ρ 5. For your information, the six planets orbits in question have these radii: Planet Orbit Radius Mercury 35.98 Venus 67.24 arth 92.90 Mars 141.60 Jupiter 483.80 Saturn 890.70 A template script is provided on the website that includes this information. You now have all the facts and ideas necessary to write Kepler.py. When it is run, the script is to display the Kepler ratios and the actual orbit-radii ratios in a table like this: Planet-Pair Kepler Actual --------------------------------- Venus:Mercury 1.73 1.87 arth:venus x.xx x.xx Mars:arth x.xx x.xx Jupiter:Mars x.xx x.xx Saturn:Jupiter x.xx x.xx We have reported the results for the Venus-Mercury ratios as a courtesy so that you can check that you are on the right track as you develop your program. Strong advice: don t try to do everything at once. Start by computing the Venus-Mercury ratios and display its line in the output table. Then proceed to handle the arth-venus ratios etc. Never move on to the next ratio computation until everything is working. The second and third columns in the table should be nicely aligned and show the ratios to two decimals. Choose good variable names and write succinct, informative comments that enable the reader to follow along as you encode the nesting process. In future assignments we will take points off for poor style and we will do it here if your effort is minimal. However, in this assignment you will just be given feedback if your commenting is substandard. Finally, you are NOT allowed to use loops or arrays should you already know about these Python constructions. Submit your finished rendition of Kepler.py to CMS. 2 You Are Late! Suppose you show up 90 minutes late for a 2:45 appointment. The receptionist says You missed your 1:15 appointment! In this problem you write a script YouAreLate.py that solicits an arrival time using raw input and then prints out the receptionist s admonition for your 90-minute mistake. Here are some sample dialogs : User responses shown in red. nter the time in the form hh:mm : 03:46 You missed your 02:16 appointment! nter the time in the form hh:mm : 03:10 You missed your 01:40 appointment! nter the time in the form hh:mm : 01:05 You missed your 11:35 appointment! nter the time in the form hh:mm : 01:50 You missed your 12:20 appointment!

Input is a length-5 string where the first two characters are and the last two characters are 01, 02,..., 11, or, 12 00, 01,..., 58, or 59 and the third character is a colon. Observe from the dialogs displayed above that the 90-minute-earlier time is to be conveyed in the same hh:mm style. Here are some examples: Arrival Time String 90-minute-arlier Time String 02:45 01:15 10:15 08:45 12:05 10:35 01:10 11:40 Two observations: 1. Regarding the minute part sometimes you subtract 30 and sometimes you add 30. 2. Regarding the hour part sometimes you subtract 1 and sometimes you subtract 2. And after you do that you may have to make an adjustment. Look at the last example in the table where the interviewee shows up at 1:10. If you subtract two hours from that you get -1:10 o clock! Here are some useful tips: Start the development of your implementation by setting up the acquisition of the input string. Use raw input. Your program may assume that the input string is in the right format. 01:34 is OK. 1:34, 123:4, one-thirty-four are not OK. Your program is not expected to handle bad input. (Later on in the course we will talk about graceful ways of handling this kind of user carelessness.) Get hold of the hour and minute portions of the input string by appropriate string slicing. Convert those substrings into integer values using int. Do the arithmetic as suggested above to compute the hour and minute values H and M of the (missed) appointment time. Make sure this part of the solution is working before proceeding further. Do this by printing out the values of H and M and confirming by hand that the calculations are correct. Make sure that your testing covers all the necessary cases. Once you get the integers H and M you have to produce the right 5-character string encoding for the 90-minute-earlier time. Remember that the str function can be used to convert an integer value like 15 to a string like 15. You will have to do some concatenation if H or M are a single digit. For example, here is how to display the integer value 5 as a 2-character string: 0 + str(5). As illustrated above, you embed your length-5 string encoding of the appointment time in an admonition string. Thus, if the appointment time is 11:40, then your script prints You missed your 11:40 appointment!. Submit your implementation of YouAreLate.py to CMS.

3 Pluralizer In this problem you write a script Pluralizer.py that prompts the user for string input using raw input and then computes and displays its plural according to these rules: 1. If the last character in the input string is y, then change the y to i and add es. For example, diary becomes diaries. 2. If the last two characters are ro, to, or no, then add es. For example hero becomes heroes, potato becomes potatoes, and volcano becomes volcanoes. 3. If the last character in the input string is s, h, or x, then add es. For example, mess becomes messes, fish becomes fishes, and sex becomes sexes. 4. If the last two characters are fe, then replace the fe with ves. For example, life becomes lives. 5. If none of the above situations apply, then just add s. For example, house becomes houses. Put aside what you know about pluralization of nglish words because the above rules can get it wrong (and that s OK). For example, according to Rule 1, boy becomes boies! Moreover, the rules can be applied to any string, not just nglish words. Thus icu2 becomes icu2s. The heart of your implementation of Pluralizer.py is an if-elif construction that handles the five situations. Your script should produce dialogs like this: nter a string: diary The plural of diary is diaries. nter a string: potato The plural of potato is potatoes. nter a string: mess The plural of mess is messes. nter a string: wife The plural of wife is wives. nter a string: 2x1+? The plural of 2x1+? is 2x1+?s Submit your implementation of Pluralizer.py to CMS.