CMSC 201 Fall 2016 Homework 6 Functions

Similar documents
CMSC 201 Spring 2017 Homework 4 Lists (and Loops and Strings)

CMSC 201 Spring 2016 Homework 7 Strings and File I/O

CMSC 201 Spring 2017 Project 1 Number Classifier

CMSC 201 Spring 2018 Project 3 Minesweeper

CMSC 201 Spring 2018 Project 2 Battleship

CS 1803 Pair Homework 3 Calculator Pair Fun Due: Wednesday, September 15th, before 6 PM Out of 100 points

CS 1803 Pair Homework 4 Greedy Scheduler (Part I) Due: Wednesday, September 29th, before 6 PM Out of 100 points

CMSC 201 Spring 2019 Lab 06 Lists

CS 2316 Individual Homework 4 Greedy Scheduler (Part I) Due: Wednesday, September 18th, before 11:55 PM Out of 100 points

CMSC 201 Spring 2018 Lab 01 Hello World

CMSC 201 Spring 2017 Lab 01 Hello World

CMSC 201 Fall 2018 Lab 04 While Loops

CMSC 201 Spring 2017 Lab 05 Lists

CS Homework 11 p. 1. CS Homework 11

Please make sure that when you submit your assignment, you submit a single HW6.py file that contains your entire assignment.

Programming Studio #1 ECE 190

CS 2316 Individual Homework 1 Python Practice Due: Wednesday, August 28th, before 11:55 PM Out of 100 points

CS Homework 4 Employee Ranker. Due: Wednesday, February 8th, before 11:55 PM Out of 100 points. Files to submit: 1. HW4.py.

CS 2316 Homework 9a GT Room Reservation Login

CS 2316 Individual Homework 5 Joint Probability Out of 100 points

CS 1803 Individual Homework 2 Conditionals & Loops Due: Wednesday, February 2 nd, before 6 PM Out of 100 points

CS 1803 Individual Homework 2 Conditionals & Loops Due: Wednesday, September 8th, before 6 PM Out of 100 points

CS Homework 4 Lifeguard Employee Ranker. Due: Tuesday, June 3rd, before 11:55 PM Out of 100 points. Files to submit: 1. HW4.py.

Ascii Art. CS 1301 Individual Homework 7 Ascii Art Due: Monday April 4 th, before 11:55pm Out of 100 points

Spring CS Homework 12 p. 1. CS Homework 12

CS Homework 11 p. 1. CS Homework 11

CS 1803 Individual Homework 1 Python Practice Due: Wednesday, January 26th, before 6 PM Out of 100 points

CS 2316 Homework 9a Login Due: Friday, November 2nd, before 11:55 PM Out of 100 points. Premise

CMSC 201 Spring 2017 Lab 12 Recursion

CS 2316 Homework 9b GT Thrift Shop Due: Wednesday, April 20 th, before 11:55 PM Out of 100 points. Premise

CS 1301 Pair Homework 4 Conditionals & Loops Due: Friday, October 1, before 6 PM Out of 100 points

CS Homework 10 p. 1. CS Homework 10

EECE.2160: ECE Application Programming

CMSC 201 Fall 2016 Lab 09 Advanced Debugging

CS 2316 Homework 9a GT Pizza Login Due: Wednesday November 6th Out of 100 points. Premise

Student Outcomes. Classwork. Opening Exercise (3 minutes) Example 1 (8 minutes)

CS Homework 10 p. 1. CS Homework 10

Homework 7: Subsets Due: 11:59 PM, Oct 23, 2018

CS 2316 Individual Homework 1 Python Practice Due: Wednesday, January 20 th, before 11:55 PM Out of 100 points

CS 1510: Intro to Computing - Fall 2017 Assignment 8: Tracking the Greats of the NBA

Homework 2. Due 4:00pm, Wednesday, February 13, Installation and Handin 2

CS 2316 Homework 9b GT Room Reservation

CSCI 4210 Operating Systems CSCI 6140 Computer Operating Systems Project 1 (document version 1.3) Process Simulation Framework

Assignment 7: Due Wednesday May 11 at 6pm UPDATES on Monday May 9

Before submitting the file project5.py, check carefully that the header above is correctly completed:

CS 1301 Pair Homework 2 Conversions Due: Monday January 27th, 2014, before 11:55pm Out of 100 points Files to submit: hw2.py

Programming Studio #1 ECE 190

CS 2316 Pair 1: Homework 3 Enigma Fun Due: Wednesday, February 1st, before 11:55 PM Out of 100 points

CMSC 201 Fall 2015 Lab 12 Tuples and Dictionaries

Project 5 Handling Bit Arrays and Pointers in C

by the evening of Tuesday, Feb 6

File Input/Output. Learning Outcomes 10/8/2012. CMSC 201 Fall 2012 Instructor: John Park Lecture Section 01. Discussion Sections 02-08, 16, 17

Homework # 7 DUE: 11:59pm November 15, 2002 NO EXTENSIONS WILL BE GIVEN

MATH 1MP3 Homework #4 Due: 11:59pm, Wednesday, March 6.

King Abdulaziz University Faculty of Computing and Information Technology Computer Science Department

CSCI 4210 Operating Systems CSCI 6140 Computer Operating Systems Homework 4 (document version 1.1) Sockets and Server Programming using C

CS Fall Homework 5 p. 1. CS Homework 5

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 3: SEP. 13TH INSTRUCTOR: JIAYIN WANG

Before submitting the file project4.py, check carefully that the header above is correctly completed:

CMSC201 Computer Science I for Majors

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 2: SEP. 8TH INSTRUCTOR: JIAYIN WANG

27-Sep CSCI 2132 Software Development Lab 4: Exploring bash and C Compilation. Faculty of Computer Science, Dalhousie University

Spring CS Homework 3 p. 1. CS Homework 3

Gold Hw8 Problem 3: TT Securities, Incorporated

CMSC201 Computer Science I for Majors

CS 202, Fall 2017 Homework #4 Balanced Search Trees and Hashing Due Date: December 18, 2017

CMSC Introduction to Database Systems

Vector: A series of scalars contained in a column or row. Dimensions: How many rows and columns a vector or matrix has.

This assignment is about using PHP together with SQL to create, modify, and query information in a database.

CS70 - Lecture 6. Graphs: Coloring; Special Graphs. 1. Review of L5 2. Planar Five Color Theorem 3. Special Graphs:

Due Friday, March 20 at 11:59 p.m. Write and submit one Java program, Sequence.java, as described on the next page.

Customise your module structure

CS2630: Computer Organization Project 2, part 1 Register file and ALU for MIPS processor

CS 2110 Fall Instructions. 1 Installing the code. Homework 4 Paint Program. 0.1 Grading, Partners, Academic Integrity, Help

Question 1: knn classification [100 points]

Homework: More Abstraction, Trees, and Lists

Assignment 3: Distance COP3330 Fall 2017

CS355 Hw 4. Interface. Due by the end of day Tuesday, March 20.

CIT 590 Homework 5 HTML Resumes

Part 6b: The effect of scale on raster calculations mean local relief and slope

Lab 1 Introduction to UNIX and C

T H E I N T E R A C T I V E S H E L L

Blocky: A Game of Falling Blocks

CMSC 201 Computer Science I for Majors

CompSci 125 Lecture 09. Chapter 5: while, break and continue statements Iterators and the ArrayList Class

sftp - secure file transfer program - how to transfer files to and from nrs-labs

CMSC 201 Fall 2016 Lab 13 More Recursion

Lecture Programming in C++ PART 1. By Assistant Professor Dr. Ali Kattan

Assignment 3, Due October 4

Overview. Task A: Getting Started. Task B: Adding Support for Current Time

Structure and Interpretation of Computer Programs

Programming Assignment #4 Arrays and Pointers

CS 241 Data Organization using C

(edit 3/7: fixed a typo in project specification 2-f) user_id that user enters should be in the range [0,n-1] (i.e., from 0 to n-1, inclusive))

Visit the TA Helpdesk (schedule posted on class website)

Important Project Dates

Individual Homework- Create Your Own Password! Due: September 15 th, 2014 Before 11:55PM Out of 100 points

CMSC 201 Spring 2016 Lab 04 For Loops

: Principles of Imperative Computation. Fall Assignment 5: Interfaces, Backtracking Search, Hash Tables

CSE548, AMS542: Analysis of Algorithms, Fall 2012 Date: October 16. In-Class Midterm. ( 11:35 AM 12:50 PM : 75 Minutes )

Transcription:

CMSC 201 Fall 2016 Homework 6 Functions Assignment: Homework 6 Functions Due Date: Wednesday, October 26th, 2016 by 8:59:59 PM Value: 40 points Collaboration: For Homework 6, collaboration is not allowed you must work individually. You may still come to office hours for help, but you may not work with any other CMSC 201 students. Make sure that you have a complete file header comment at the top of each file, and that all of the information is correctly filled out. # File: FILENAME.py # Author: YOUR NAME # Date: THE DATE # Section: YOUR DISCUSSION SECTION NUMBER # E-mail: YOUR_EMAIL@umbc.edu # Description: # DESCRIPTION OF WHAT THE PROGRAM DOES # Collaboration: # COLLABORATION STATEMENT GOES HERE CMSC 201 Computer Science I for Majors Page 1

Homework 6 is designed to help you practice using all of the structures we have learned so far. You will also get significant practice with creating and calling functions. Remember to enable Python 3 before running and testing your code: scl enable python33 bash Instructions In this homework, you will be doing a series of exercises designed to help you practice creating different functions, and calling them to perform tasks as needed. Each one of these exercises should be in a separate python file. For this assignment, you may assume that all the input you get will be of the correct type (e.g., if you ask the user for a whole number, they will give you an integer). For this assignment, you'll need to follow the class coding standards, a set of rules designed to make your code clear and readable. The class coding standards are on the website, linked at the top of the Assignments page. You can also access them directly via this URL (http://goo.gl/yeogfc). At the end, your Homework 6 file must run without any errors. Details Homework 6 is broken up into four separate parts. Make sure to complete all 4 parts. Although Homework 6 is broken up into four parts, you will be turning in a single file at the end, with all four of your functions contained inside it. The single file should be called hw6.py. NOTE: Your filename for this homework must match the given one exactly. And remember, filenames are case sensitive! CMSC 201 Computer Science I for Majors Page 2

Questions Each question is worth the indicated number of points. Following the coding standards, having complete file headers, and having the correctly named file is worth 4 points. For Homework 6, you will be creating a single file, called hw6.py, that contains four separate functions: summation() multiply() createintlist() main() Each function is described in detail below. Adhere to the coding standards by including function header comments for each of the functions (other than main). Follow the instructions and example provided in the coding standards document when creating your function header comments. Failing to include function header comments will lose you points. You are highly encouraged to test each function fully before moving on to the next. Using a temporary main() to interact with each function as you develop and test it may prove useful. Pay close attention to the sample output provided when testing your own code. CMSC 201 Computer Science I for Majors Page 3

Part 1 summation() (Worth 7 points) The summation() function should take in a list of integers and return their sum. You may not use Python s built-in functions to calculate the sum. If the list of integers is empty, the sum should be 0. Sample output for this function can be found at the end of the assignment description. Part2 multiply() (Worth 7 points) The multiply() function should take in a list of integers and return their product (the number computed by multiplying all of the numbers together). You may not use Python s built-in functions to calculate the product. If the list of integers is empty, the product should be 0. Sample output for this function can be found at the end of the assignment description. Part3 createintlist() (Worth 9 points) The createintlist() function takes in a sentinel value (an integer), and returns a list of integers. The function prompts the user to create a list of integers, using the provided sentinel value as the number the user enters to exit the creation of the list. Sample output for this function can be found at the end of the assignment description. CMSC 201 Computer Science I for Majors Page 4

Part4 main() (Worth 13 points) The final main() function uses the three functions that you have already written to implement a simple math helper program. The program should: Ask the user how many lists they want to create For each list: o Tell the user which number list they are creating (starting at 1) o Ask the user for their desired sentinel value o Create a lists of integers (using the given sentinel value) o Calculate the summation o Calculate the product o Print out: The entire list The summation of the list The product of the list Continue until the desired number of lists have been gathered, and their information has been printed to the user (WARNING: It is not advised to attempt this part of the homework until you have completed and fully tested the first three parts.) See the following pages for sample output, with the user input in blue. (Yours does not have to match this exactly, but it should be similar.) CMSC 201 Computer Science I for Majors Page 5

How many lists would you like to create? 0 How many lists would you like to create? 1 You are creating list #1 What do you want the sentinel to be? 0 Please enter a number, 0 to stop: 1 Please enter a number, 0 to stop: 2 Please enter a number, 0 to stop: 3 Please enter a number, 0 to stop: 4 Please enter a number, 0 to stop: 5 Please enter a number, 0 to stop: 6 Please enter a number, 0 to stop: 7 Please enter a number, 0 to stop: 8 Please enter a number, 0 to stop: 9 Please enter a number, 0 to stop: 10 Please enter a number, 0 to stop: -9 Please enter a number, 0 to stop: -3 Please enter a number, 0 to stop: -1 Please enter a number, 0 to stop: 0 For the list [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -9, -3, -1] The summation is 42 The product is -97977600 (Additional sample output on the next page.) CMSC 201 Computer Science I for Majors Page 6

How many lists would you like to create? 3 You are creating list #1 What do you want the sentinel to be? 0 Please enter a number, 0 to stop: 0 For the list [] The summation is 0 The product is 0 You are creating list #2 What do you want the sentinel to be? -1 Please enter a number, -1 to stop: 5 Please enter a number, -1 to stop: 6 Please enter a number, -1 to stop: 7 Please enter a number, -1 to stop: 8 Please enter a number, -1 to stop: 0 Please enter a number, -1 to stop: -2 Please enter a number, -1 to stop: -1 For the list [5, 6, 7, 8, 0, -2] The summation is 24 The product is 0 You are creating list #3 What do you want the sentinel to be? -999 Please enter a number, -999 to stop: -88 Please enter a number, -999 to stop: 50 Please enter a number, -999 to stop: 2 Please enter a number, -999 to stop: 10 Please enter a number, -999 to stop: 1 Please enter a number, -999 to stop: 3 Please enter a number, -999 to stop: 4 Please enter a number, -999 to stop: -999 For the list [-88, 50, 2, 10, 1, 3, 4] The summation is -18 The product is -1056000 (Additional sample output on the next page.) CMSC 201 Computer Science I for Majors Page 7

How many lists would you like to create? 1 You are creating list #1 What do you want the sentinel to be? 0 Please enter a number, 0 to stop: 1 Please enter a number, 0 to stop: 0 For the list [1] The summation is 1 The product is 1 How many lists would you like to create? -1 How many lists would you like to create? -2 CMSC 201 Computer Science I for Majors Page 8

Submitting Once your hw6.py file is complete, it is time to turn it in with the submit command. (You may turn in the file multiple times as you complete each function. To do so, simply submit hw6.py each time you complete a part of the homework. Each new submit will overwrite the old file.) You must be logged into your GL account, and you must be in the same directory as your Homework 6 python file. To double-check this, you can type ls. linux1[3]% ls hw6.py linux1[4]% To submit your Homework 6 python files, we use the submit command, where the class is cs201, and the assignment is HW6. Type in (all on one line) submit cs201 HW6 hw6.py and press enter. linux1[4]% submit cs201 HW6 hw6.py Submitting hw6.py...ok linux1[5]% If you don t get a confirmation like the one above, check that you have not made any typos or errors in the command. You can check that your homework was submitted by following the directions in Homework 0. Double-check that you submitted your homework correctly, since an empty file will result in a grade of zero for this assignment. CMSC 201 Computer Science I for Majors Page 9