CSCI 150: Exam 1 Practice

Similar documents
CSCI 150: Exam 1 Practice

CSCI 150: Exam 1 Practice

Assessment - Unit 3 lessons 16-21

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

Text Input and Conditionals

Navigation coordinate systems

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

CS 1301 Exam 1 Fall 2009

CS 1301 Exam 1 Answers Fall 2009

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.

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

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

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

Making Decisions In Python

Unit 7: Algorithms and Python CS 101, Fall 2018

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

Read this before starting!

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

CIMA Certificate BA Interactive Timetable

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

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

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

Section 1.2: Points and Lines

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

AIMMS Function Reference - Date Time Related Identifiers

Creating Mercator s Map Projection

Comp 151. Control structures.

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

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

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.

Checking Multiple Conditions

(Python) Chapter 3: Repetition

Question: Total Points: Score:

Indicate the option which most accurately completes the sentence.

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

Read this before starting!

Fortran programming for beginner seismologists Lesson 6

Smart Series. Wall Heater Operations Manual. Save This Manual

15110 PRINCIPLES OF COMPUTING SAMPLE EXAM 2

Midterm Exam 2B Answer key

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

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

Boolean Data-Type. Boolean Data Type (false, true) i.e. 3/6/2018. The type bool is also described as being an integer: bool bflag; bflag = true;

KING FAHD UNIVERSITY OF PETROLEUM & MINERALS COMPUTER ENGINEERING DEPARTMENT

age = 23 age = age + 1 data types Integers Floating-point numbers Strings Booleans loosely typed age = In my 20s

Pupil Name. Year. Teacher. Target Level. Key Stage 3 Self-Assessment Year 9 Python. Spelling Test No 3. Spelling Test No 2. Spelling Test No 1

CSE 131 Introduction to Computer Science Fall Exam I

DSC 201: Data Analysis & Visualization

Read this before starting!

Digital Fundamentals

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

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

Conditionals/Branching

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

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

Comp 151. Control structures.

Computer Science 217

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

Read this before starting!

Question 1. Part (a) Simple Syntax [1 mark] Circle add_ints(), because it is missing arguments to the function call. Part (b) Simple Syntax [1 mark]

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

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

CS150 Sample Final Solution

Parallel and Distributed Computing

Boolean evaluation and if statements. Making decisions in programs

Introduction. Primitive Data Types: Integer. Primitive Data Types. ICOM 4036 Programming Languages

Fundamentals of Programming (Python) Getting Started with Programming

CSE 131 Introduction to Computer Science Fall Exam I

HN1000/HN2000 Product Manual

CS150 Sample Final. Name: Section: A / B

Lecture 1. Course Overview, Python Basics

Part III Appendices 165

Test #2 October 8, 2015

4. Write the output that would be printed from each of the following code fragments. (8pts) x = 9 y = x / 2 print('y ==', y) +1 4.

Maintaining the Central Management System Database

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

Computer Science 217

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

Private Swimming Lessons

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

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

A453 Task 1: Analysis: Problem: Solution:

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

Lecture 1. Course Overview, Python Basics

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

Midterm Exam 2A Principles of Computing Fall November 10, 2014

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

PREPARING FOR PRELIM 1

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

Question: Total Points: Score:

Program Planning, Data Comparisons, Strings

OPERATING MANUAL- MODEL : BS-101

NESTED IF STATEMENTS AND STRING/INTEGER CONVERSION

CMSC201 Computer Science I for Majors

INTERMEDIATE LEVEL PYTHON PROGRAMMING SELECTION AND CONDITIONALS V1.0

A quick look at the basic functions of the Hercules Programmable Controller by

CS 106B Lecture 2: C++ Functions

Arithmetic and Bitwise Operations on Binary Data

Getting Started with Python

Transcription:

CSCI 150: Exam 1 Practice Instructor: Mark Goadrich and Gabriel Ferrer September 13, 2016 Read all questions carefully before beginning. You will have 1 hour 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. Find at least 5 syntax errors in the following program and say why they are incorrect: x == input("what is your age? ") y = print("at age " + x / 2 + " who was your hero?) if age > 20: if y == "Batman": print("you are now the savior Gotham deserves.") else print "Why not Zoidberg?") if x!= 19 or 20 and y!= "Yakko Warner" print("good night!") elif: print("your path is unique. Carry on, brave warrior.") 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