def instructions(response): # Add to instruction_string so that it contains information on # how to play rock-paper-scissors instruction_string = ""

Similar documents
6.149 Checkoff 2. What to complete. Recall: Creating a file and running a program in IDLE.

CS 150 Lab 10 Functions and Random Numbers

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

COGS3 JavaScript Module!! JavaScript Codecademy part A: rock paper scissors part B: add n subtract partc: slideshow. Put it in: public_html/hw6

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

LOOPS. Repetition using the while statement

CONDITION CONTROLLED LOOPS. Introduction to Programming - Python

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

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

How to Setup Google Apps With Your Domain

University of New Mexico Department of Computer Science. Final Examination. CS 561 Data Structures and Algorithms Fall, 2011

CME 193: Introduction to Scientific Python Lecture 1: Introduction

Here is a sample IDLE window illustrating the use of these two functions:

Condition Controlled Loops. Introduction to Programming - Python

Lab 2: Booleans, Strings, Random Numbers, Recursion, Variables, Input function

Due Date: Two Program Demonstrations (Testing and Debugging): End of Lab

Lab 1: Space Invaders. The Introduction

EECS2031 Winter Software Tools. Assignment 1 (15%): Shell Programming

Honors Computer Science Python Mr. Clausen Programs 4A, 4B, 4C, 4D, 4E, 4F

VISUAL GUIDE to. RX Scripting. for Roulette Xtreme - System Designer 2.0. L J Howell UX Software Ver. 1.0

Lab 1: Simon. The Introduction

CS 1110, LAB 1: PYTHON EXPRESSIONS.

(Python) Chapter 3: Repetition

TWO PLAYER REACTION GAME

The name of our class will be Yo. Type that in where it says Class Name. Don t hit the OK button yet.

Lab 1: Setup 12:00 PM, Sep 10, 2017

Python Problems MTH 151. Texas A&M University. November 8, 2017

ROCK PAPER SCISSORS Rock Paper Scissors Lab Project Using C or C++

15-110: Principles of Computing, Spring 2018

How To Think Like A Computer Scientist, chapter 3; chapter 6, sections

Real Python: Python 3 Cheat Sheet

Instant Teambuilding, v3.0. User s Manual. Instant Teambuilding 2012, 2017 Kagan Publishing

Text Input and Conditionals

In this lab, you will learn more about selection statements. You will get familiar to

COPYRIGHTED MATERIAL. Starting Strong with Visual C# 2005 Express Edition

Lecture 1. Types, Expressions, & Variables

Exercise 2: Automata Theory

6.S189 Homework 2. What to turn in. Exercise 3.1 Defining A Function. Exercise 3.2 Math Module.

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

Introduction to: Computers & Programming: Review prior to 2 nd Midterm

Lab 4: Bash Scripting

Introduction to Programming with JES

CMSC 201 Fall 2016 Lab 09 Advanced Debugging

Introduction to CS. Welcome to CS 5! 1 handout. We don't have words strong enough to describe this class. Everyone will get out of this course a lot!

CS 112: Intro to Comp Prog

Lab 1: Input, Processing, and Output This lab accompanies Chapter 2 of Starting Out with Programming Logic & Design.

Linux Operating System Environment Computadors Grau en Ciència i Enginyeria de Dades Q2

CHECKOUT CUSTOM FIELD FOR MAGENTO 2

Math Day 2 Programming: How to make computers do math for you

CPSC 150 Laboratory Manual. Lab 1 Introduction to Program Creation

Part III Appendices 165

CMSC 201 Fall 2018 Lab 04 While Loops

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

Intramural Game Mode Tutorial

Programming for Engineers in Python. Recitation 1

CSci 1113: Introduction to C/C++ Programming for Scientists and Engineers Homework 10 Spring 2018

(Ca...

Remaining Enhanced Labs

Solving Equations with Inverse Operations

Intro. Scheme Basics. scm> 5 5. scm>

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

Intro to Programming. Unit 7. What is Programming? What is Programming? Intro to Programming

Masternode Guide Version 1.0.4

Lab 2: Booleans, Strings, Random Numbers, Recursion, Variables, Input function

IT Training Services. SharePoint 2013 Getting Started. Version: 2015/2016 V1

Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science Introductory Digital Systems Laboratory

Login and identity management

Building a Django Twilio Programmable Chat Application

1. What statistic did the wc -l command show? (do man wc to get the answer) A. The number of bytes B. The number of lines C. The number of words

IACUC Researcher s Quick Reference

Programming for Engineers in Python. Autumn

Python for Non-programmers

Classwork 7: Craps. N. Duong & R. Rodriguez, Java Crash Course January 6, 2015

Solar Campaign Google Guide. PART 1 Google Drive

There are several files including the start of a unit test and the method stubs in MindNumber.java. Here is a preview of what you will do:

FRONT USER GUIDE Getting Started with Front

Click IACUC Researcher s Quick Reference

Lab 1 Implementing a Simon Says Game

Parametric Lab. Thursday, September 17th, 8:00am - 5:10pm Phil Ringsmuth,

Lecture 9. Assignment. Logical Operations. Logical Operations - Motivation 2/8/18

Hello, World! An Easy Intro to Python & Programming. Jack Rosenthal

Lecture 3. Input, Output and Data Types

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

Oracle Cloud. Content and Experience Cloud ios Mobile Help E

If Statements, For Loops, Functions

CPSC 217 Assignment 3

Name 8-6A. 1. What type of quadrilateral is shown below? A Rectangle B Trapezoid C Rhombus D Square. 2. What is true about every rhombus?

MIT Programming Contest Team Contest 1 Problems 2008

Lecture 2: Variables & Assignments

GETTING TO KNOW CASE FEED

Intro to Python & Programming. C-START Python PD Workshop

(I m not printing out these notes! Take your own.)

Scientific Programming Algolab. Wednesday 21 Dec 2016

LAB 5: SELECTION STATEMENTS

Unit 7: Algorithms and Python CS 101, Fall 2018

TJ IOI Practice Programming Round. Thomas Jefferson High School for Science and Technology

Lesson 5C MyClass Methods. By John B. Owen All rights reserved 2011, revised 2014

Lab 1 Implementing a Simon Says Game

BR-80 Digital Recorder

Data Lab: Manipulating Bits

Transcription:

Python Team Project Large development projects are rarely done by one person alone. Instead most developers work in teams. Thus, understanding how to divide up work and collaborate are essential to computer programming. In this project you will work in teams of two. To get started talk over the following points with your teammate. It is also recommended that you put your division of work in writing as you will need to turn in a summary of your team experiences. Introduce yourself. Share your computer background. Discuss if you have common time to get together outside of class. Review the materials for this assignment. Determine your strategy for completing the game. Example strategies are: 1. Assign different functions of the game to different team members, then integrate and test. 2. Decide if you want to work on the same file, or work in separate files, combining them as you go. 3. Have one team member type the program, while working and discussing the implementation together. 4. Have one team member type the program, while working and discussing the implementation together. Halfway through switch roles. 5. Have one team member implement, while another team member tests 6. Be sure your strategy includes how you will test the code during programming, don t wait until it is all done to test. 7. Other ideas To start, go to the assignment page and left click on the link titled rps.tar. Select the radio button titled Save File then execute the following commands. denver: ~ $ cd python fun denver: ~ /python fun$ mkdir team project denver: ~ /python fun$ cd team project denver: ~ /python fun/team project$ mv ~ /Downloads/rps.tar./ denver: ~ /python fun/team project$ tar xvf rps.tar denver: ~ /python fun/team project$ chmod +x rps.py denver: ~ /python fun/team project$ gedit rps back.py & denver: ~ /python fun/team project$./rps.py When you click Start Game in the window that appeared, the game should close and you should get a message on you console that says Not implemented yet. This is OK, you will add the implementation. 1

Some things to note, the x in the top right corner of the game window does not always work, instead use the Quit button in the bottom left corner to quit the game. Also we are working with Python version 2.7 in this assignment because the libraries used were written in this version. The only notable difference here is that the print function does not use parentheses any more. Project Description For this project you will be implementing the back end for a Rock, Paper, Scissors game. This means that you will write the part that actually handles the game. The front end (presentation part) has already been implemented and you will use it as a library. The file rps.py is the front end for the game. This is also the file that you will run from the command line. This program will call your functions and depends on them working for a fully functional game. You will not make any changes to the rps.py file. All changes you make will be made to rps back.py. You will also be using the library matplotlib, which we used in the last lab. Getting Started The first function we will start with is instructions. The current code in this function is shown below. def instructions(response): # Add to instruction_string so that it contains information on # how to play rock-paper-scissors instruction_string = "" # Use a string method to make response all one case # Use an if statement to check if the response is "yes" # If the user does want instructions pass instruction_string to # rps.print_instructions To start, we need to fill instruction string with the correct instructions for Rock, Paper, Scissors. Add the following code to this function. instruction_string = "Choose rock, paper, or scissors from the buttons. " instruction_string += "The computer will then choose a move. " instruction_string += "Rock beats scissors, scissors beats paper, and paper beats rock." Now that we have the instructions ready, we need to check the response. The response can be in any case, but we should only display the instructions if they respond yes. Without having 2

to check all the combinations of casings, let s just make the string all lower case and match that with yes. Add the following line below the comment line that says: Use a string... response = response.lower() Finally we use an if statement and call rps.print instructions if the response was yes. Add the following line below the comment line that says Use an if statement... if response == "yes": rps.print_instructions(instruction_string) Now you need to test it to make sure it works! The play match function is where the program execution starts, so lets go to that function and add the following line to the beginning. Note that this should be the first statement in the function. rps.ask_instructions() When any form of yes is entered you should see a screen with your instructions, any other input should skip this screen and the game should close (because nothing else is implemented yet). Test other cases to make sure that it is working well. Now that you have a feel on how to make changes and test, continue to add implementation for your game based on the strategy that you and your partner have decided on. Pay attention to the order in which you add code to make sure you can test as you go along. If you get lost, brainstorm with your partner, look at the rps hints.py file on the assignment page, look at previous python labs for this class, consult google, ask one of the instructors/class helpers, come to office hours, look at the optional functions descriptions below. i.e. there are lots of strategies for help! Function Descriptions (optional clarifications) 0.1 play match Your main function will be play match, which will be called almost immediately when you run the rps.py program. Here you will need to call three separate functions from rps. rps.ask instructions This functions will prompt the user if they need instructions. Their response will be passed along to your instructions function. There is not return value from this call. rps.get name This function prompts the user for their name, then calls your function titled check name. The return value is what you return from check name. 3

rps.get num play This function prompts the user for how many times they would like to play. The response is then passed to your check times to play function. The return value is what you return from check times to play. It is recommended you implement the following functions, in the order presented, before finishing with play match. 0.2 instructions This function takes one parameter, response. This variable contains the users response to the prompt Would you like instructions (yes/no):. If this response is yes, in any combination of case, call rps.print instructions, passing it a string variable which has instructions for how to play Rock, Paper, Scissors. 0.3 check name For this function you will need to check that the parameter name starts with an uppercase letter, is of length greater than one and less than ten, and that it is only one name (i.e. no spaces). If any of these requirements are not met call rps.quit game, passing a string with an appropriate error message. If the name is OK, then return it. 0.4 check times to play This function is similar to check name. You are passed a variable num which you must check that it is greater than two and less than twenty one. If these requirements are not met call rps.quit game, passing a string with the error message. If the number is OK, then return the integer version of it (it comes in as a string). 0.5 play game This function takes one parameter, the name of the player. You must get the players move by calling rps.get player move, which will return a string of what the player chose. You then must generate a move for the computer using the random.random function (note this returns a decimal number from zero, inclusive, to one, exclusive). Once you have the computers move and the players move, determine who one. Call rps.display results with a string that spans three lines, and describes the players move, the computers move, and who won (or tied). Finally, return a string describing who won. 4

0.6 play match Once the other functions are working (and you can test them by calling them from this function) you will need to add the rest of the implementation for play match. This function will call play game the number of times that was received from rps.get num play. Think about how you can use a while loop to do this (or look up for loop python on google and use that). You must keep a running tally of the number of times the player won, the computer won, and ties. At the end of the loop call make graph, with parameters for the name of the player, number of wins for the player, number of wins for the computer, and number of ties (in that exact order). 0.7 make graph Using the parameters you must create a graph to appropriately display the results of the Rock, Paper, Scissors game. The type of graph is up to you. Look to the last lab, or the link to the documentation to get a template of how to make the graph. Submission When your code is working correctly refer to the assignment page for submission instructions. 5