CSCI 150: Exam 1 Practice

Similar documents
CSCI 150: Exam 1 Practice

CSCI 150: Exam 1 Practice

BUP2 5/2 12/4/07 12:49 AM Page 1. Introduction

Assessment - Unit 3 lessons 16-21

UNCA CSCI 255 Exam 1 Spring February, This is a closed book and closed notes exam. It is to be turned in by 1:45 PM.

ECE 2030D Computer Engineering Spring problems, 5 pages Exam Two 8 March 2012

Navigation coordinate systems

SUMMER Early Registration Begins On... Summer Hours. Tuition (per child): JUNE 2019

Making Decisions In Python

Section 1.2: Points and Lines

Text Input and Conditionals

CIMA Certificate BA Interactive Timetable

PASCAL. PASCAL, like BASIC, is a computer language. However, PASCAL, unlike BASIC, is a Blocked Structured Language (BASIC is known as unstructured).

AIMMS Function Reference - Date Time Related Identifiers

CS 202: Introduction to Computation Fall 2010: Exam #1

Computer Science 217

Unit 7: Algorithms and Python CS 101, Fall 2018

New York University Introduction to Computer Science Midterm2 Sample Problems 2013 Andrew I. Case. Instructions:

Model: TM-1 / TM1-N. 1 Time Clock Series

Read this before starting!

In addition to the correct answer, you MUST show all your work in order to receive full credit.

Grade 6 Math Circles October 16 & Non-Euclidean Geometry and the Globe

CS 1301 Exam 1 Answers Fall 2009

CS 1301 Exam 1 Fall 2009

CS 455 Midterm Exam 1 Fall 2015 [Bono] Thursday, Oct. 1, 2015

BUT2 7day 11/4/07 11:07 PM Page 1. Introduction

Creating Mercator s Map Projection

Q1: Multiple choice / 20 Q2: C input/output; operators / 40 Q3: Conditional statements / 40 TOTAL SCORE / 100 EXTRA CREDIT / 10

CS 1301 Exam 1 Fall 2014

Grade 6 Math Circles October 16 & Non-Euclidean Geometry and the Globe

NAME: 1a. (10 pts.) Describe the characteristics of numbers for which this floating-point data type is well-suited. Give an example.

Indicate the option which most accurately completes the sentence.

Lecture 1. Course Overview, Python Basics

Pre-Calculus Advanced. Chapter 10 Part 2. Period 8

CS16 Exam #1 7/17/ Minutes 100 Points total

HN1000/HN2000 Product Manual

Chapter. Solving Problems that Require Decisions. Objectives: At the end of the chapter students should be able to:

Read this before starting!

15110 PRINCIPLES OF COMPUTING SAMPLE EXAM 2

Midterm Exam 2B Answer key

Computer Science Grade 10 Sample -Term 2 Date: February 2018 Time: TBC Duration: 45 minutes

Lecture 1. Course Overview, Python Basics

ECE 2030B 1:00pm Computer Engineering Spring problems, 5 pages Exam Two 10 March 2010

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

Cambridge English Dates and Fees for 2018

Read this before starting!

CS 1301 Exam 1 Fall 2014

First name (printed): a. DO NOT OPEN YOUR EXAM BOOKLET UNTIL YOU HAVE BEEN TOLD TO BEGIN.

ECE 2020B Fundamentals of Digital Design Spring problems, 6 pages Exam Two 26 February 2014

Digital Fundamentals

OPERATING MANUAL FOR AUTOMATIC SCHOOL BELL Ringing bell in manual mode: When unit is at Home Screen, showing date and time on

Python - Week 3. Mohammad Shokoohi-Yekta

CS & IT Conversions. Magnitude 10,000 1,

University of Toronto Department of Electrical and Computer Engineering. Midterm Examination. ECE 345 Algorithms and Data Structures Fall 2012

Introduction to Computer Programming CSCI-UA 2. Review Midterm Exam 1

Birkbeck (University of London) MSc Examination. Department of Computer Science and Information Systems. Fundamentals of Computing (COIY058H7)

Read this before starting!

Getting Started with Java Using Alice. 1 Copyright 2013, Oracle and/or its affiliates. All rights reserved.

CDA 3103 Computer Organization Exam 1 (Sep. 22th, 2014)

Introduction to programming using Python

Parallel and Distributed Computing

CS150 Sample Final Solution

Python The way of a program. Srinidhi H Asst Professor Dept of CSE, MSRIT

CS150 Sample Final. Name: Section: A / B

Test #2 October 8, 2015

CS 1301 Exam 1 Spring 2014

Question: Total Points: Score:

SECONDARY SCHOOL, L-IMRIEĦEL HALF YEARLY EXAMINATIONS 2016/2017

Comp 151. Control structures.

CS 115 Exam 1, Fall 2015 Thu. 09/24/2015

Decisions, Decisions, Decisions. GEEN163 Introduction to Computer Programming

Computer Science 217

GIRLS SECONDARY, L-IMRIEĦEL HALF YEARLY EXAMINATIONS 2015/2016

Discrete Mathematics and Probability Theory Spring 2016 Rao and Walrand Midterm 1

UNIT 7A Data Representation: Numbers and Text. Digital Data

Fortran programming for beginner seismologists Lesson 6

Total Score /15 /20 /30 /10 /5 /20 Grader

CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON

MATH 211 FINAL EXAM REVIEW PROBLEMS. c. Illustrating 12-7 for the take away concept of subtraction

Binary. Hexadecimal BINARY CODED DECIMAL

Computer Science 217

Copy: IF THE PROGRAM or OUTPUT is Copied, then both will have grade zero.

KING FAHD UNIVERSITY OF PETROLEUM & MINERALS COMPUTER ENGINEERING DEPARTMENT

CS 1301 Exam 1 Spring 2014

CSE100 Principles of Programming with C++

PREPARING FOR PRELIM 1

OPERATING MANUAL- MODEL : BS-101

DSC 201: Data Analysis & Visualization

Scheduling. Scheduling Tasks At Creation Time CHAPTER

CSCI 131, Midterm Exam 1 Review Questions This sheet is intended to help you prepare for the first exam in this course. The following topics have

AQA Decision 1 Algorithms. Section 1: Communicating an algorithm

Program Planning, Data Comparisons, Strings

Name Feb. 14, Closed Book/Closed Notes No electronic devices of any kind! 3. Do not look at anyone else s exam or let anyone else look at yours!

Arithmetic and Bitwise Operations on Binary Data

PLEASE HAND IN UNIVERSITY OF TORONTO Faculty of Arts and Science

Outline. 1 If Statement. 2 While Statement. 3 For Statement. 4 Nesting. 5 Applications. 6 Other Conditional and Loop Constructs 2 / 19

Optimization Problems and Wrap-Up. CS 221 Lecture 14 Tue 6 December 2011

Lecture 1. Types, Expressions, & Variables

The Size of the Cantor Set

Checking Multiple Conditions

Transcription:

CSCI 150: Exam 1 Practice Instructor: Brent Yorgey February 5, 2018 Read all questions carefully before beginning. You will have 50 minutes to complete this exam. You are not allowed to use your notes, textbook, phone, calculator, or computer. Show all your work for full credit. 1. The color Cornflower Blue is defined as the hexadecimal number #6495ED. Find the amount of blue in this color, written as a number between 0 and 255. 2. September 13th is World Programmers Day, because it is the 256th day of the year. What is the binary representation of 92 (the 92nd day of the year is April 1st)? 1

3. You are given the following Python definitions: a = 2 b = 3 c = 23.8 d = True e = False Evaluate the truth value of each Python expression below: e or c > a (d and e) or (not d and not e) (a / b) > 0 and d ((a * b) - 12) == 9 2

4. Two trains a and b are on a collision course heading down the same track. If you know the speed of the two trains and how far apart they are, you can calculate when they will collide by the following formula: collision = distance speed a + speed b. Write a program that asks the user for the speed of the two trains and their distance, calculates how long before the trains collide using the above formula, and prints the result to the screen. Be sure to include an informative message with the result, for example, Time until the trains collide: 3.862049. 3

5. You want to write a program that will tell you when to set your alarm clock. You have the input section already written, such that there is an integer variable for day according to 0=Sun, 1=Mon, 2=Tue,..., 6=Sat, and a boolean variable vacation indicating if you are on vacation. Now you are writing the logic, so that the program will print a string of the form 7:00 indicating when the alarm clock should ring. Normally, on weekdays (Monday through Friday) the alarm should print 7:00 and on the weekend (Saturday or Sunday) it should print 10:00. Unless you are on vacation then on weekdays it should print 10:00 and weekends it should print off. This is your first attempt and it is wrong. Show two examples of values for day and vacation that produce incorrect output and clearly state the semantic errors with the code. if vacation and day > 5: print("off") else: if day > 0 or day < 6: print("7:00") else: print("10:00") 4

6. Trace the execution of the following Python program, by writing down the values of all variables and any output produced by the program. Make sure to clearly separate values of variables from output, and make sure to clearly indicate what values the variables have at the end of the program. Showing your work (e.g. evaluation of expressions) is not required but makes it much easier to give partial credit if you make a mistake. i = 3 animal = cat if i < 1 or (animal == cat and i > 1): i = i + 1 animal = dog print("yay") elif animal == dog and i > 1: i = i + 1 animal = pig print("boo") if i > 5: i = i * 3 print(animal) else: i = i - 2 print("no " + animal) 5

Extra practice Distance bewteen two points The shortest distance between two points is usually a straight line. However, the shortest distance between two locations on Earth is calculated with the great circle distance. Given two locations, this distance in kilometers is where 6371.01 acos(sin(φ s ) sin(φ f ) + cos(φ s ) cos(φ f ) cos(λ s λ f )), φ s is the latitude of the starting point, λ s is the longitude of the starting point, φ f is the latitude of the final point, and λ f is the longitude of the final point. Write a program that asks the user for the latitude and longitude of two locations in decimal form, calculates the distance between them using the above formula, and prints the result to the screen. Mercator projection The Mercator Projection, formulated in 1569 by Gerardus Mercator, is the most commonly used 2D map projection of the globe and is seen on school walls across America. It has the property that compass bearings are accurately displayed, and is extremely useful for nautical purposes. Given a latitude φ and longitude λ, and using the Prime Meridian as the center of the map, we can find the x, y coordinate projection by: x = λ y = 1 ( ) 1 + sin(φ) 2 ln 1 sin(φ) Write a Python program to prompt the user for input of floating-point numbers for phi (φ) and lambda (λ), perform the above calculations, and then display the corresponding x, y coordinates to the user. Note, ln is the natural logarithm with base e. 6

Shoe sizes European and American shoe sizes differ by a standard amount. You can approximate the European shoe size by using the following formulas. For men: eurosize = 9 americansize + 30.5 7 For women: eurosize = 9 americansize + 29 7 Write a program that asks the user for the American shoe size and gender, calculates the European shoe size using the above formula, and prints the result to the screen. 7