Computer Science 217



Similar documents
Outline. hardware components programming environments. installing Python executing Python code. decimal and binary notations running Sage

Introduction to Python

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.

Informatica e Sistemi in Tempo Reale

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

Sources: On the Web: Slides will be available on:

CSI 333 Lecture 1 Number Systems

Base Conversion written by Cathy Saxton

Computer Programming. Course Details An Introduction to Computational Tools. Prof. Mauro Gaspari:

Computer Programming I & II*

The programming language C. sws1 1

CS 106 Introduction to Computer Science I

Bachelors of Computer Application Programming Principle & Algorithm (BCA-S102T)

Product: DQ Order Manager Release Notes

Exercise 4 Learning Python language fundamentals

Python Lists and Loops

Charles Dierbach. Wiley

HOMEWORK # 2 SOLUTIO

Introduction to Java

Introduction to Computers and Programming

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

Machine Architecture and Number Systems. Major Computer Components. Schematic Diagram of a Computer. The CPU. The Bus. Main Memory.

QUIZ-II QUIZ-II. Chapter 5: Control Structures II (Repetition) Objectives. Objectives (cont d.) 20/11/2015. EEE 117 Computer Programming Fall

River Dell Regional School District. Computer Programming with Python Curriculum

Chapter One Introduction to Programming

Chapter 7D The Java Virtual Machine

Subject knowledge requirements for entry into computer science teacher training. Expert group s recommendations

Python. KS3 Programming Workbook. Name. ICT Teacher Form. Do you speak Parseltongue?

WESTMORELAND COUNTY PUBLIC SCHOOLS Integrated Instructional Pacing Guide and Checklist Computer Math

Module 10. Coding and Testing. Version 2 CSE IIT, Kharagpur

Computers. An Introduction to Programming with Python. Programming Languages. Programs and Programming. CCHSG Visit June Dr.-Ing.

Programming Languages CIS 443

CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013

Welcome to Introduction to programming in Python

Memory is implemented as an array of electronic switches

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

ALGORITHMS AND FLOWCHARTS

AQA GCSE in Computer Science Computer Science Microsoft IT Academy Mapping

a) What is the major difference between a program that runs under a virtual machine vs. one that does not?

Binary Number System. 16. Binary Numbers. Base 10 digits: Base 2 digits: 0 1

Introduction to Python

Memory Management Simulation Interactive Lab

ESCI 386 Scientific Programming, Analysis and Visualization with Python. Lesson 5 Program Control

Translating to Java. Translation. Input. Many Level Translations. read, get, input, ask, request. Requirements Design Algorithm Java Machine Language

Copyright 2012 Pearson Education, Inc. Chapter 1 INTRODUCTION TO COMPUTING AND ENGINEERING PROBLEM SOLVING

Objectives. Python Programming: An Introduction to Computer Science. Lab 01. What we ll learn in this class

Goals. Unary Numbers. Decimal Numbers. 3,148 is s 100 s 10 s 1 s. Number Bases 1/12/2009. COMP370 Intro to Computer Architecture 1

Solution for Homework 2

Eventia Log Parsing Editor 1.0 Administration Guide

APPENDIX B. Routers route based on the network number. The router that delivers the data packet to the correct destination host uses the host ID.

I PUC - Computer Science. Practical s Syllabus. Contents

CS106A, Stanford Handout #38. Strings and Chars

Pemrograman Dasar. Basic Elements Of Java

Visual Logic Instructions and Assignments

(Refer Slide Time: 01.26)

C Programming. for Embedded Microcontrollers. Warwick A. Smith. Postbus 11. Elektor International Media BV. 6114ZG Susteren The Netherlands

Useful Number Systems

#820 Computer Programming 1A

Instructional Design Philosophy

Access Queries (Office 2003)

The Hexadecimal Number System and Memory Addressing

Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program.

Using Format Manager For Creating Format Files

PROG0101 Fundamentals of Programming PROG0101 FUNDAMENTALS OF PROGRAMMING. Chapter 3 Algorithms

Quiz for Chapter 1 Computer Abstractions and Technology 3.10

Management Challenge. Managing Hardware Assets. Central Processing Unit. What is a Computer System?

Memory Systems. Static Random Access Memory (SRAM) Cell

Python Programming: An Introduction to Computer Science

Model Simulation in Rational Software Architect: Business Process Simulation

Testing and Inspecting to Ensure High Quality

Teaching Pre-Algebra in PowerPoint

find model parameters, to validate models, and to develop inputs for models. c 1994 Raj Jain 7.1

Practical Programming, 2nd Edition

Chapter 2 Writing Simple Programs

J a v a Quiz (Unit 3, Test 0 Practice)

Exercises for Design of Test Cases

Embedded Systems. Review of ANSI C Topics. A Review of ANSI C and Considerations for Embedded C Programming. Basic features of C

Chapter 13: Program Development and Programming Languages

2003 HSC Notes from the Marking Centre Software Design and Development

What is a Loop? Pretest Loops in C++ Types of Loop Testing. Count-controlled loops. Loops can be...

1. Convert the following base 10 numbers into 8-bit 2 s complement notation 0, -1, -12

EMC Publishing. Ontario Curriculum Computer and Information Science Grade 11

University of Toronto Department of Electrical and Computer Engineering. Midterm Examination. CSC467 Compilers and Interpreters Fall Semester, 2005

CSCI 4717 Computer Architecture. Function. Data Storage. Data Processing. Data movement to a peripheral. Data Movement

CSCI 3136 Principles of Programming Languages

VB.NET Programming Fundamentals

Lesson 07: MS ACCESS - Handout. Introduction to database (30 mins)

Number Representation

Handout 1. Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner.

RAM & ROM Based Digital Design. ECE 152A Winter 2012

Encoding Text with a Small Alphabet

Management Information Systems 260 Web Programming Fall 2006 (CRN: 42459)

ASSEMBLY PROGRAMMING ON A VIRTUAL COMPUTER

CS 40 Computing for the Web

Decision Logic: if, if else, switch, Boolean conditions and variables

Writing Simple Programs

Computer Programming Tutorial

Decimal Number (base 10) Binary Number (base 2)

1 The Java Virtual Machine

Transcription:

Computer Science 217 Midterm Exam Fall 2009 October 29, 2009 Name: ID: Instructions: Neatly print your name and ID number in the spaces provided above. Pick the best answer for each multiple choice question. Answer each question by writing the correct answer in the space provided. Answer all multiple choice questions using UPPER CASE letters. This exam consists of 11 pages, including the cover. Before answering any questions count the pages and ensure that they are all present. You have 1 hour 15 minutes to complete this exam. Unless noted otherwise, each question is worth one mark. This exam is closed book. You are not permitted to use any electronic devices or reference materials. DO NOT TURN PAST THIS PAGE UNTIL YOU ARE INSTRUCTED TO BEGIN Page 1

1. The area of computer science that studies techniques for coordinating the behavior of many computers, and problems such as race conditions and deadlock is known as: A. Distributed Systems B. Human Computer Interaction C. Information Visualization D. Software Engineering E. Theory of Computation 2. Early electronic computers, such as ENIAC, were constructed using: A. Bridges B. Pipes C. Relays D. Transistors E. Vacuum Tubes 3. In a modern computer, which of the following components is not normally connected to the north bridge? A. Central Processing Unit B. Graphics Subsystem C. Keyboard D. Main Memory (RAM) E. None of the above answers are correct 4. The process of breaking a problem down into 3 to 5 steps, and then repeating the process for steps that are still too complex is referred to as: A. Evaluation B. Programming C. Software Engineering D. Synthesis E. Top Down Design 5. Within Bloom s Taxonomy, the level of comprehension that is characterized by the ability to infer causes or predict consequences is known as: 6. (2 marks) Consider the following list of variable names that are being considered for use in a Python program. Some of these names can be used in a Python program, while others are illegal. Circle all of the names that are allowed to be used. 3aaas ComputerScienceDepartment _exam_count follow-up if print r2d2 Then zzz Page 2

7. Which of the following statements is most correct? A. Python is a low level programming language that exposes many details of the computer s hardware. B. Python has been used in industry to create successful products. C. The shortest correct Python program that can be created is 3 lines long. D. Exactly two of the above answers are correct. E. Answers A, B, and C are all correct. 8. Which of the following statements is most correct? A. When a program is compiled, the resulting executable file can be executed on any type of computer. B. Using a virtual machine provides the best method of protecting the source code for your program from competitors. C. Using a virtual machine generally provides superior performance to a compiled executable. D. More than one of the above answers is correct. E. None of the above answers are correct. 9. Consider the following expression that could appear in a Python program. z = 2 + 2 ** 2 * 2-2 After it is evaluated, the value of z will be: 10. Consider a program that generates some output and then crashes. The error in this program would be classified as a: A. Condition Error B. Logic Error C. Path Error D. Runtime Error E. Syntax Error Page 3

11. Consider the following code segment: a = raw_input() b = input() c = a + b print c When the program is run, the user first enters 10 and then 5. The output generated by the program will be: A. 5 B. 10 C. 15 D. 105 E. None of the above answers are correct 12. Consider a program that includes a variable named x which contains a floating point number. Write a single line of code that uses a format specifier to display the value of x, rounded to 3 decimal places. 13. Convert 221 base 5 to base 10. _ Page 4

14. Convert 157 base 10 to hexadecimal. _ 15. (2 marks) Convert 365 base 7 to base 4. _ Page 5

16. (2 marks) Convert 330 base 4 to base 9. _ 17. What was the primary motivation for developing UTF-8? 18. Consider the following sequence of bits: 0100 1010 1101 1111 0110 1010 1011 1100. Inside of a computer, these bits will always be treated as: A. A character B. A color C. A real number D. An integer E. None of the above answers are correct Page 6

19. Consider the logical expression (A and (not B)) or C. In the truth table for this expression, the number of rows for which the expression evaluates to true is: Consider the following code segment: x = input() if (x < 2000): print "A" elif (x < 1000): print "B" else: print "C" 20. If the user enters 500 for x then the output from this program will be: 21. If the user enters 2000 for x then the output from this program will be: Page 7

Consider the following code segment: x = input("enter x: ") y = input("enter y: ") if x >= 2: y = y + 1 print x if y > 3: x = x - 1 print y x = x - 1 elif x == 1: print x x = x + 1 if y <= 3: print x else: print y 22. If the user enters 1 and 3 when prompted, the output from this program will be: 23. If the user enters 3 and 1 when prompted, the output from this program will be: 24. If the user enters 2 and 2 when prompted, the output from this program will be: 25. Which of the following operators has the highest precedence? A.!= B. < C. + D. * E. and 26. What level of white-box test coverage provides the greatest level of assurance that your program is free of bugs? A. Condition coverage B. Graph coverage C. Heuristic coverage D. Path coverage E. Statement coverage Page 8

27. Consider the following Python code segment: if a < b: print "That's good..." elif a >= b: print "Even better!" if c == d: print "c is equal to d!" print "All done!" How many test cases are required to achieve path level test coverage for this code segment? 28. Which of the following statements is most correct? A. In Python, both while loops and for loops are pre-tested loops. B. In Python, while loops are pre-tested loops. For loops are post-tested loops. C. In Python, while loops are post-tested loops. For loops are pre-tested loops. D. In Python, both while loops and for loops are post-tested loops. E. None of the above statements are correct. Consider the following code segment. Recall that when the % operator is applied to two integers it computes the remainder of dividing the left number by the right number. a = input() b = input() while (a < b): a = a + 1 if (a % 2) == 0: b = b - 2 print (a + b) 29. If the user enters 0 for a, and 0 for b, then the value displayed by the program will be: 30. If the user enters 2 for a and 10 for b, then the value displayed by the program will be: 31. If the user enters 5 for a and 10 for b, then the value displayed by the program will be: 32. How many copies of the letter X does the following program display? for i in range(1, 1000): j = 0 while (j < 5): print "X" j = j + 1 Page 9

33. (12 marks) Write a program that draws the first n rows of a number triangle where each row is represented by the numbers 1.. row_number.. 1. For example, if the user entered 4, your program should output the following 4 rows: 1 1 2 1 1 2 3 2 1 1 2 3 4 3 2 1 Similarly, if the user entered 6 for n then your program should output: 1 1 2 1 1 2 3 2 1 1 2 3 4 3 2 1 1 2 3 4 5 4 3 2 1 1 2 3 4 5 6 5 4 3 2 1 As a final example, if the user entered 1 then your program should output: 1 If the user enters a value for n that is less than or equal to zero then your program should display a meaningful error message. No numeric output should be displayed if the error message is generated. Provide an appropriate prompt for the user. Hint: print statements in Python normally print whatever values have been requested, and then move down to the next line. If you want to print something and remain on the same line, include a comma as the last character on the line. For example: print Hello World displays Hello World and moves down to the next line, while print Hello World, displays Hello World without moving down to the next line. Your program does not need to include comments. Please take care to write clearly. If we can t read your solution then we can t give you credit for it. Page 10

Place your answer to the programming question on this page. Page 11