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

Similar documents
CS 2316 Pair 1: Homework 3 Enigma Fun Due: Wednesday, February 1st, before 11:55 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

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

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

CS 1301 Pair Homework 4 Conditionals & Loops Due: Friday, October 1, before 6 PM 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 1 Python Practice Due: Wednesday, January 26th, before 6 PM Out of 100 points

CS 1803 Pair Homework 10 Newsvendor Inventory Policy Due: Monday, November 29th before 6:00 PM Out of 100 points

Ascii Art. CS 1301 Individual Homework 7 Ascii Art Due: Monday April 4 th, before 11:55pm 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 Homework 9a GT Pizza Login Due: Wednesday November 6th Out of 100 points. Premise

CS 2316 Individual Homework 5 Joint Probability Out of 100 points

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

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

CS 2316 Individual Homework 1 Python Practice Due: Wednesday, August 28th, before 11:55 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.

CS 1301 Individual Homework 3 Conditionals & Loops Due: Monday February 8 th before 11:55pm Out of 100 points

CMSC 201 Fall 2016 Homework 6 Functions

Visit the TA Helpdesk (schedule posted on class website)

CS 1301 Homework Robot Web Writer

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

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

Functional Programming, Classes, and Recursion!

This homework has an opportunity for substantial extra credit, which is described at the end of this document.

CS 2316 Homework 9b GT Room Reservation

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

61A Lecture 3. Friday, September 5

Basic Data Types and Operators CS 8: Introduction to Computer Science, Winter 2019 Lecture #2

CS1 Lecture 3 Jan. 22, 2018

SAMS Programming A/B. Lecture #1 Introductions July 3, Mark Stehlik

Programming in C++ PART 2

CS1 Lecture 3 Jan. 18, 2019

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

Welcome to CS61A! Last modified: Thu Jan 23 03:58: CS61A: Lecture #1 1

CS 111X - Fall Test 1

Programming for Engineers in Python. Autumn

CpSc 1111 Lab 4 Part a Flow Control, Branching, and Formatting

61A LECTURE 1 FUNCTIONS, VALUES. Steven Tang and Eric Tzeng June 24, 2013

CpSc 1011 Lab 4 Formatting and Flow Control Windchill Temps

Programming for Engineers in Python. Recitation 1

Math 180 Written Homework Solutions Assignment #1 Due Thursday, September 4th at the beginning of your discussion class.

CpSc 111 Lab 5 Conditional Statements, Loops, the Math Library, and Redirecting Input

CMSC 201 Computer Science I for Majors

Programming Studio #1 ECE 190

CpSc 1111 Lab 5 Formatting and Flow Control

CpSc 1011 Lab 5 Conditional Statements, Loops, ASCII code, and Redirecting Input Characters and Hurricanes

Python Activity 7: Looping Structures WHILE Loops

Algorithms and Programming I. Lecture#12 Spring 2015

CS 111X - Fall Test 1 - KEY KEY KEY KEY KEY KEY KEY

CMSC 201 Spring 2019 Lab 06 Lists

CSE 504: Compiler Design

CS 1301 Exam 1 Fall 2009

CMSC 201 Spring 2017 Project 1 Number Classifier

Project 1. due date Sunday July 8, 2018, 12:00 noon

Lecture 2: Variables & Assignments

Lab 1: Silver Dollar Game 1 CSCI 2101B Fall 2018

CpSc 1111 Lab 6 Conditional Statements, Loops, the Math Library, and Random Numbers What s the Point?

COMP 105 Homework: Type Systems

CIS192 Python Programming. Robert Rand. August 27, 2015

Condition Controlled Loops. Introduction to Programming - Python

Using the Computer for Essays

Genome Sciences 373: Genome Informatics. Quiz section #1 March 29, 2018

Claremont McKenna College Computer Science

CS 302: Introduction to Programming in Java. Lecture 9

CS 126 Lecture P1: Introduction to C

CSCI 136 Data Structures & Advanced Programming. Fall 2018 Instructors Bill Lenhart & Bill Jannen

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

HW3: CS 110X C Domain Information. Final Version: 1/29/2014

LAB 4.1 Relational Operators and the if Statement

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

CPSC 121: Models of Computation Assignment #5

CS 4800: Algorithms & Data. Lecture 1 January 10, 2017

Tips from the experts: How to waste a lot of time on this assignment

CS 1301 Exam 1 Answers Fall 2009

About this Course. Blackboard Student Orientation Course. About the Portal. Logging In. About the Course Layout. Showing the Course Menu

CS 241 Data Organization. August 21, 2018

Homework 8 Lights, Camera, Robot Action! Due: Friday, April 13th, before 11:55 PM EST Out of 200 points Files to submit: {filmingcode.

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

CME 193: Introduction to Scientific Python Lecture 1: Introduction

CS 115 Lecture 8. Selection: the if statement. Neil Moore

Midterm Review Topics Java Basics and Structure Variables Branching Loops Methods Arrays. Midterm Review Kage Weiss Lab 001 TA, SPR 17

61A Lecture 4. Monday, September 9

CS61A Lecture 1. Amir Kamil UC Berkeley January 23, 2013

Lecture 1. Course Overview Types & Expressions

CS 112: Intro to Comp Prog

CS1 Lecture 5 Jan. 25, 2019

Laboratory 5: Implementing Loops and Loop Control Strategies

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

DEBUGGING TIPS. 1 Introduction COMPUTER SCIENCE 61A

Introduction to Scientific Python, CME 193 Jan. 9, web.stanford.edu/~ermartin/teaching/cme193-winter15

6.S189 Homework 1. What to turn in. Exercise 1.1 Installing Python. Exercise 1.2 Hello, world!

Outline. Announcements. Homework 2. Boolean expressions 10/12/2007. Announcements Homework 2 questions. Boolean expression

COSE212: Programming Languages. Lecture 0 Course Overview

CIS192: Python Programming

CpSc 1111 Lab 4 Formatting and Flow Control

Reviewing all Topics this term

CMSC 201 Fall 2018 Lab 04 While Loops

Control Structures. A program can proceed: Sequentially Selectively (branch) - making a choice Repetitively (iteratively) - looping

CS2 Practical 1 CS2A 22/09/2004

Transcription:

CS 1803 Pair Homework 3 Calculator Pair Fun Due: Wednesday, September 15th, before 6 PM Out of 100 points Files to submit: 1. HW3.py This is a PAIR PROGRAMMING Assignment: Work with your partner! For pair programming assignments, you and your partner should turn in identical assignments. List both partners names at the top. Your submission must not be substantially similar to another pairs' submission. Collaboration at a reasonable level will not result in substantially similar code. Students may only collaborate with fellow students currently taking CS 1803, the TA's and the lecturer. Collaboration means talking through problems, assisting with debugging, explaining a concept, etc. You should not exchange code or write code for others. For Help: - TA Helpdesk Schedule posted on class website. - Email TA's or use T-Square Forums Notes: Don t forget to include the required comments and collaboration statement (as outlined on the course syllabus). Do not wait until the last minute to do this assignment in case you run into problems. User Interaction You will write a few python functions for practice with user interaction and string and list processing. In your HW3.py file, include a comment at the top with your names, section, GTID/Emails, and your collaboration statement. Also include each of the following functions. 1. getinteger 2. getmathop 3. getyesno() 4. docalculation() 5. calculator()

Function Name: getinteger string A String which will be shown to the user to prompt them. An integer. getinteger( Please enter an integer: ) Please enter an integer: 10 If the user typed a valid integer (as above), return the integer the user entered; in this case, getinteger returns 10 getinteger( Please enter an integer: ) Please enter an integer: Hello World Not a valid number, try again Please enter an integer: +-/* Not a valid number, try again Please enter an integer: 5 getinteger returns 5 Write a function that will accept one parameter, a string, and show it to the user. The function should then get input from the user and convert it into an integer. Return the integer value. If the user does not enter a proper integer, your function must tell them that they entered an invalid number using the warning: Not a valid number, try again... Then, show the prompt again, and allow them to try and type another integer. Keep repeating until the user enters digits that can be successfully converted to an integer. Function Name: getmathop string - a String which will be shown to the user to prompt them. A string with one of four values: +, -, *, or / getmathop( Please enter one of the four permitted math operations: ) Please enter one of the four permitted math operations: + If the user typed a valid math operation, return the string representing the math operation; in this case, getmathop returns + getmathop( Please enter one of the four permitted math operations: ) Please enter one of the four permitted math operations: Hello World You may only enter one of the characters: +-*/ Please enter one of the four permitted math operations: +-/*

You may only enter the one of the characters: +-*/ Please enter one of the four permitted math operations: 17 You may only enter the one of the characters: +-*/ Please enter one of the four permitted math operations: * getmathop returns * Write a function that takes in a string to use as a prompt and shows it to the user. Then get input from the user. If they entered a single sign out of the set +,-,*,/, return it. If they entered anything else, give them a warning: You may only enter one of the characters: + - * / and then repeat until they enter a correct option. Function Name: getyesno string a string to show the user as a prompt. boolean True if the user entered Y/yes/Yes/YES/y, etc... False if the user entered N/NO/No/nO/n, etc... >>>getyesno( Do you want to continue? ) Do you want to continue? I don't know Not a valid answer, enter Y or N. Do you want to continue? Yes Returns ---> True Write a function that takes in a string as a prompt to the user. It should display that string and get input from the user. If the user enters Y, or y, or YES, or Yes, or yes, or YeS or yes, or any other permutation of lower and upper case letters that spells out a yes, return true. If they enter N, or n, or NO, or no, return False. If they enter anything else, give them the error Not a valid answer, enter Y or N. and then repeat the question until they give a valid answer. Function Name: docalculation Float Result of calculation. Test Case: >>> docalculation() Enter your first number: 3 Enter your math operation: + Enter your second number: 5 Returns 8.0

Write a function that gets an integer, an operation, and a second integer from the user. After getting those three items (it may call other functions that you have written to do this work) it should perform the appropriate calculation and return the result. Note that your result must be converted to a float, even if it was an integer. Function Name: calculator() Enter your first number: 3 Enter your math operation: + Enter your second number: 5 Your answer is: 8.0 Would you like to perform another calculation? (y or n) Y Enter your first number: 10 Enter your math operation: * Enter your second number: 2 Your answer is: 20.0 Would you like to perform another calculation? (y or n) N The results of your last 2 calculations were: 8.0 20.0 Goodbye! Write a function that uses your other functions to allow the user to do multiple calculations. After each calculation, ask the user if they want to do another calculation. Be sure to save the results of each calculation as they go! Once the user says they do not want to do any more calculations, print a final message that states the total number of calculations they performed, and lists the results (final answer) of each calculation before saying Goodbye!

Grading: You will earn points as follows for each function that works correctly according to the specifications. getinteger 20 properly handles negative numbers: -5 1 Properly handles leading spaces: 35 1 Properly handles trailing spaces: 34 1 Properly shows prompt 5 Properly returns answer 5 Properly handles invalid input: ten 7 getmathop 20 Properly shows prompt 3 Property handles leading spaces: + 5 Property handles trailing spaces: + 5 Property handles invalid input: times 7 getyesno() 20 Properly shows prompt. 3 Properly handles leading spaces: Yes 3 Properly handles trailing spaces: Y 3 Properly handles invalid input: Nope 11 docalculation() 20 Does the right calculation 10 Returns the proper value (as float) 10 calculator() 20 Allows multiple calculations 5 Correctly allows user to quit 3 Prints correct messages 2 Remembers /prints number & value of results 10